|
| 1 | +--- |
| 2 | +layout: docs |
| 3 | +title: BreadCrumb |
| 4 | +description: Indicate the current page's location within a navigational hierarchy that automatically adds separators via CSS. |
| 5 | +group: components |
| 6 | +--- |
| 7 | + |
| 8 | +import { BreadCrumb } from 'boot-cell/source/Navigator/BreadCrumb'; |
| 9 | + |
| 10 | +## Example |
| 11 | + |
| 12 | +<BreadCrumb path={[{ title: 'Home' }]} /> |
| 13 | + |
| 14 | +```javascript |
| 15 | +<BreadCrumb path={[{ title: 'Home' }]} /> |
| 16 | +``` |
| 17 | + |
| 18 | +<BreadCrumb path={[{ href: '#', title: 'Home' }, { title: 'Library' }]} /> |
| 19 | + |
| 20 | +```javascript |
| 21 | +<BreadCrumb path={[{ href: '#', title: 'Home' }, { title: 'Library' }]} /> |
| 22 | +``` |
| 23 | + |
| 24 | +<BreadCrumb |
| 25 | + path={[ |
| 26 | + { href: '#', title: 'Home' }, |
| 27 | + { href: '#', title: 'Library' }, |
| 28 | + { title: 'Data' } |
| 29 | + ]} |
| 30 | +/> |
| 31 | + |
| 32 | +```javascript |
| 33 | +<BreadCrumb |
| 34 | + path={[ |
| 35 | + { href: '#', title: 'Home' }, |
| 36 | + { href: '#', title: 'Library' }, |
| 37 | + { title: 'Data' } |
| 38 | + ]} |
| 39 | +/> |
| 40 | +``` |
| 41 | + |
| 42 | +## Changing the separator |
| 43 | + |
| 44 | +Separators are automatically added in CSS through [`::before`](https://developer.mozilla.org/en-US/docs/Web/CSS/::before) and [`content`](https://developer.mozilla.org/en-US/docs/Web/CSS/content). They can be changed by changing `$breadcrumb-divider`. The [quote](https://sass-lang.com/documentation/functions/string#quote) function is needed to generate the quotes around a string, so if you want `>` as separator, you can use this: |
| 45 | + |
| 46 | +```scss |
| 47 | +$breadcrumb-divider: quote('>'); |
| 48 | +``` |
| 49 | + |
| 50 | +It's also possible to use an **embedded SVG icon**: |
| 51 | + |
| 52 | +```scss |
| 53 | +$breadcrumb-divider: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E%3Cpath d='M2.5 0L1 1.5 3.5 4 1 6.5 2.5 8l4-4-4-4z' fill='currentColor'/%3E%3C/svg%3E"); |
| 54 | +``` |
| 55 | + |
| 56 | +The separator can be removed by setting `$breadcrumb-divider` to `none`: |
| 57 | + |
| 58 | +```scss |
| 59 | +$breadcrumb-divider: none; |
| 60 | +``` |
| 61 | + |
| 62 | +## Accessibility |
| 63 | + |
| 64 | +Since breadcrumbs provide a navigation, it's a good idea to add a meaningful label such as `aria-label="breadcrumb"` to describe the type of navigation provided in the `<nav>` element, as well as applying an `aria-current="page"` to the last item of the set to indicate that it represents the current page. |
| 65 | + |
| 66 | +For more information, see the [WAI-ARIA Authoring Practices for the breadcrumb pattern](https://www.w3.org/TR/wai-aria-practices/#breadcrumb). |
0 commit comments