Breadcrumbs
Navigation breadcrumb trail with slash separator.
Code
components/Breadcrumbs.astro
---interface BreadcrumbItem { label: string; href?: string;} interface Props { items: BreadcrumbItem[]; class?: string;} const { items, class: className = "" } = Astro.props;--- <nav aria-label="Breadcrumb" class={`breadcrumbs ${className}`}> <ol> {items.map((item, i) => ( <li> {i > 0 && <span class="breadcrumb-separator" aria-hidden="true">/</span>} {item.href ? ( <a href={item.href} class="breadcrumb-link">{item.label}</a> ) : ( <span class="breadcrumb-current">{item.label}</span> )} </li> ))} </ol></nav>
Preview
Usage
<Breadcrumbs items={[ { label: "Home", href: "/" }, { label: "Docs", href: "/docs" }, { label: "Components" }, ]}/>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| items | BreadcrumbItem[] | — | Array of breadcrumb items with label and optional href. |
| class | string | — | Additional CSS classes. |