Breadcrumbs from path
A breadcrumb built from the current URL path.
SourceStyles source@monoline/react 0.4.0Markdown for AI toolsbeta
- Built on native elements
- Same as Breadcrumb: a navigation landmark with an ordered list; the last crumb is the current page and not a link.
- Styles in one file:
18-navigation.css
Import
import '@monoline/css';
import {BreadcrumbsAuto} from '@monoline/react';
Not installed yet? Pick a route.
Copies the source and its styles into your project.
npx monoline add breadcrumbs-auto
Usage
import {BreadcrumbsAuto} from '@monoline/react';
<BreadcrumbsAuto pathname="/projects/website-redesign/settings" labels={{'website-redesign': 'Website redesign'}} />
Examples
From a path
Pass `pathname` from your router. Give a segment a nicer label with `labels`.
Props
BreadcrumbsAutoProps
| Prop | Type | Default | Description |
|---|---|---|---|
pathname required | string | – | The current URL path, from your router: `/settings/billing`. Query and hash are ignored. |
labels | Record<string, string> | {} | Text for a path segment, keyed by the segment: `{billing: 'Billing and plans'}`. Others are the segment with dashes as spaces, capitalised. |
homeLabel | string | 'Home' | Text of the first crumb, which links to `/`. Default "Home". |
Data Attributes
State is exposed through attributes. Style it with these selectors, not with class toggles.
| Attribute | Stylesheet |
|---|---|
[aria-current="page"] | 18-navigation.css |
[aria-current="step"] | 18-navigation.css |
[aria-selected="true"] | 18-navigation.css |
[data-state="done"] | 18-navigation.css |
CSS classes
| Class | Stylesheet |
|---|---|
.brand | 18-navigation.css |
.crumbs | 18-navigation.css |
.pager | 18-navigation.css |
.step | 18-navigation.css |
.steps | 18-navigation.css |
.tab | 18-navigation.css |
.tabpanel | 18-navigation.css |
.topbar | 18-navigation.css |
.topbar-nav | 18-navigation.css |
.divider | 09-links.css |
.link | 09-links.css |
.skip-link | 09-links.css |
Customization
Style it with the kit's tokens in your own CSS, loaded after @monoline/css. Prefer the attributes above over extra classes. See Theming for every token.
app.css
.brand {
border-color: var(--accent);
}
.brand[aria-current="page"] {
background: var(--wash);
}
Accessibility
- Same as Breadcrumb: a navigation landmark with an ordered list; the last crumb is the current page and not a link.