Components Navigation
Breadcrumb
Show the current location within a sequence of parent destinations.
Usage
Set Label to the navigation landmark name. Each item has a Label and Href. Mark the final item with Current to render it as the current location.
Register breadcrumb with Head and pass its properties to Render. Go setup guide
Go usage
err := mono.UI.Render(w, "breadcrumb", mono.Props{
"Items": []any{
map[string]any{
"Href": "/index.html",
"Label": "Mono",
},
map[string]any{
"Href": "/docs.html",
"Label": "Reference",
},
map[string]any{
"Current": true,
"Label": "Typography",
},
},
"Label": "Breadcrumb",
})Rendered HTML
<nav data-mono="breadcrumb" id="demo-breadcrumb" aria-label="Breadcrumb">
<ol><li><a href="/index.html">Mono</a></li><li><a href="/docs.html">Reference</a></li><li><span aria-current="page">Typography</span></li></ol>
</nav>Go template
<nav data-mono="breadcrumb" id="{{.ID}}" aria-label="{{.Label}}">
<ol>{{range .Items}}<li>{{if .Current}}<span aria-current="page">{{.Label}}</span>{{else}}<a href="{{.Href}}">{{.Label}}</a>{{end}}</li>{{end}}</ol>
</nav>Component CSS
[data-mono="breadcrumb"] ol { display:flex; flex-wrap:wrap; align-items:center; list-style:none; margin:0; padding:0; gap:.5rem; font-size:.9rem; }
[data-mono="breadcrumb"] li { display:inline-flex; align-items:center; gap:.5rem; }
[data-mono="breadcrumb"] li + li::before { content:""; flex:none; width:.875rem; height:.875rem; background:currentColor; color:var(--mu-muted); mask:var(--mu-chevron) center / contain no-repeat; forced-color-adjust:none; }
[data-mono="breadcrumb"] a { color:#555; text-decoration:underline; text-underline-offset:.2rem; }
[data-mono="breadcrumb"] [aria-current] { font-weight:650; }Use the HTML in a static site
Copy the rendered HTML above. Download these assets into the same folder as your page, then add the tags below to its head.
<link rel="stylesheet" href="./base.css">
<link rel="stylesheet" href="./breadcrumb.css">Copy into your project
Run this command from the Mono checkout. Set -out to the component directory in your application.
go run ./cmd/mono-ui add -out ./components breadcrumbExample properties (JSON)
{
"Items": [
{
"Href": "/index.html",
"Label": "Mono"
},
{
"Href": "/docs.html",
"Label": "Reference"
},
{
"Current": true,
"Label": "Typography"
}
],
"Label": "Breadcrumb"
}