# Breadcrumbs ## Introduction The Breadcrumbs component helps users to understand where they are within a website’s structure and move between levels. ## Guidance Find out when to use the breadcrumbs component in your service in the [GOV.UK Design System](https://design-system.service.gov.uk/components/breadcrumbs). ## Quick start examples ### Breadcrumbs [Preview this example in the Frontend review app](http://govuk-frontend-review.herokuapp.com/components/breadcrumbs/preview) #### Markup
#### Macro {% from "breadcrumbs/macro.njk" import govukBreadcrumbs %} {{ govukBreadcrumbs({ "items": [ { "text": "Section", "href": "/section" }, { "text": "Sub-section", "href": "/section/sub-section" } ] }) }} ### Breadcrumbs with one level [Preview this example in the Frontend review app](http://govuk-frontend-review.herokuapp.com/components/breadcrumbs/with-one-level/preview) #### Markup #### Macro {% from "breadcrumbs/macro.njk" import govukBreadcrumbs %} {{ govukBreadcrumbs({ "items": [ { "text": "Section", "href": "/section" } ] }) }} ### Breadcrumbs with multiple levels [Preview this example in the Frontend review app](http://govuk-frontend-review.herokuapp.com/components/breadcrumbs/with-multiple-levels/preview) #### Markup #### Macro {% from "breadcrumbs/macro.njk" import govukBreadcrumbs %} {{ govukBreadcrumbs({ "items": [ { "text": "Home", "href": "/" }, { "text": "Section", "href": "/section" }, { "text": "Sub-section", "href": "/section/sub-section" }, { "text": "Sub Sub-section", "href": "/section/sub-section/sub-sub-section" } ] }) }} ### Breadcrumbs without the home section [Preview this example in the Frontend review app](http://govuk-frontend-review.herokuapp.com/components/breadcrumbs/without-the-home-section/preview) #### Markup #### Macro {% from "breadcrumbs/macro.njk" import govukBreadcrumbs %} {{ govukBreadcrumbs({ "items": [ { "text": "Service Manual", "href": "/service-manual" }, { "text": "Agile Delivery", "href": "/service-manual/agile-delivery" } ] }) }} ### Breadcrumbs with last breadcrumb as current page [Preview this example in the Frontend review app](http://govuk-frontend-review.herokuapp.com/components/breadcrumbs/with-last-breadcrumb-as-current-page/preview) #### Markup #### Macro {% from "breadcrumbs/macro.njk" import govukBreadcrumbs %} {{ govukBreadcrumbs({ "items": [ { "text": "Home", "href": "/" }, { "text": "Passports, travel and living abroad", "href": "/browse/abroad" }, { "text": "Travel abroad" } ] }) }} ## Requirements ### Build tool configuration When compiling the Sass files you'll need to define includePaths to reference the node_modules directory. Below is a sample configuration using gulp .pipe(sass({ includePaths: 'node_modules/' })) ### Static asset path configuration In order to include the images used in the components, you need to configure your app to show these assets. Below is a sample configuration using Express js: app.use('/assets', express.static(path.join(__dirname, '/node_modules/govuk-frontend/assets'))) ## Component arguments If you are using Nunjucks,then macros take the following arguments **If you’re using Nunjucks macros in production be aware that using `html` arguments, or ones ending with `Html` can be a [security risk](https://en.wikipedia.org/wiki/Cross-site_scripting). More about it in the [Nunjucks documentation](https://mozilla.github.io/nunjucks/api.html#user-defined-templates-warning).**Name | Type | Required | Description |
---|---|---|---|
items | array | Yes | Array of breadcrumbs item objects. |
items.{}.text (or) items.{}.html | string | Yes | Text or HTML to use within the breadcrumbs item. If `html` is provided, the `text` argument will be ignored. |
items.{}.href | string | no | Link for the breadcrumbs item. If not specified, breadcrumbs item is a normal list item |
items.{}.attributes | object | No | Any extra HTML attributes (for example data attributes) to add to the breadcrumb anchor item. |
classes | string | No | Optional additional classes to add to the breadcrumbs container. |
attributes | object | No | Any extra HTML attributes (for example data attributes) to add to the breadcrumbs container. |