Breadcrumb
Navigation breadcrumb trail with overflow collapsing. Supports icons, custom separators, and click or href navigation per item.
import { Breadcrumb } from "phoundry-ui";Basic
Loading interactive example…
View source
<script lang="ts"> import { Breadcrumb } from "phoundry-ui"; import type { BreadcrumbItem } from "phoundry-ui";
let lastClicked = $state("");
const basicItems: BreadcrumbItem[] = [ { id: "home", label: "Home" }, { id: "docs", label: "Docs" }, { id: "breadcrumb", label: "Breadcrumb" }, ];</script>
<Breadcrumb items={basicItems} onnavigate={(item: BreadcrumbItem) => { lastClicked = item.label; }}/>{#if lastClicked} <p class="mt-2 text-xs text-txt-tertiary">Clicked: {lastClicked}</p>{/if}With Icons
Loading interactive example…
View source
<script lang="ts"> import { Breadcrumb } from "phoundry-ui"; import type { BreadcrumbItem } from "phoundry-ui"; import { PhiIcons } from "phoundry-ui";
let lastClicked = $state("");
const iconItems: BreadcrumbItem[] = [ { id: "home", label: "Home", icon: PhiIcons.folder }, { id: "projects", label: "Projects", icon: PhiIcons.document }, { id: "phoundry-ui", label: "Phoundry UI", icon: PhiIcons.edit }, { id: "components", label: "Components" }, ];</script>
<Breadcrumb items={iconItems} onnavigate={(item: BreadcrumbItem) => { lastClicked = item.label; }}/>Collapsed Overflow (maxVisible=3)
Loading interactive example…
View source
<script lang="ts"> import { Breadcrumb } from "phoundry-ui"; import type { BreadcrumbItem } from "phoundry-ui"; import { PhiIcons } from "phoundry-ui";
let lastClicked = $state("");
const longItems: BreadcrumbItem[] = [ { id: "home", label: "Home", icon: PhiIcons.folder }, { id: "workspace", label: "Workspace" }, { id: "projects", label: "Projects" }, { id: "phoundry-ui", label: "Phoundry UI" }, { id: "components", label: "Components" }, { id: "navigation", label: "Navigation" }, { id: "breadcrumb", label: "Breadcrumb" }, ];</script>
<Breadcrumb items={longItems} maxVisible={3} onnavigate={(item: BreadcrumbItem) => { lastClicked = item.label; }}/><p class="mt-2 text-xs text-txt-tertiary"> 7 items, showing first + last 2 with an overflow menu for the rest.</p>Separator + larger size
Loading interactive example…
View source
<script lang="ts"> import { Breadcrumb } from "phoundry-ui"; import type { BreadcrumbItem } from "phoundry-ui";
const basicItems: BreadcrumbItem[] = [ { id: "home", label: "Home" }, { id: "docs", label: "Docs" }, { id: "breadcrumb", label: "Breadcrumb" }, ];</script>
<p class="mb-2 text-xs text-txt-secondary"> Use <code>separator</code> for brand-specific glyphs; <code>size="md"</code> bumps text and icon metrics.</p><Breadcrumb items={basicItems} separator="›" size="md" />Links vs buttons
Loading interactive example…
View source
<script lang="ts"> import { Breadcrumb } from "phoundry-ui"; import type { BreadcrumbItem } from "phoundry-ui"; import { PhiIcons } from "phoundry-ui";
const hrefItems: BreadcrumbItem[] = [ { id: "home", label: "Home", href: "#bc-h-home", icon: PhiIcons.folder }, { id: "docs", label: "Docs", href: "#bc-h-docs" }, { id: "here", label: "Current page" }, ];</script>
<p class="mb-2 text-xs text-txt-secondary"> Segments with <code>href</code> render as real links for middle crumbs; the last segment stays plain text. Use <code>onnavigate</code> when you route with a SPA helper instead.</p><Breadcrumb items={hrefItems} />API
From phoundry-ui@0.4.21
| Name | Type | Default | Description |
|---|---|---|---|
itemsrequired | BreadcrumbItem[] | — | Breadcrumb segments in order. |
onnavigate | (item: BreadcrumbItem) => void | — | Called when a breadcrumb is clicked. |
separator | string | '/' | Separator character between items. |
maxVisible | number | — | Max segments to show before collapsing middle items into a dropdown. |
size | "sm" | "md" | 'sm' | Text and icon size. |
class | string | '' | Additional CSS classes. |
BreadcrumbItem
From phoundry-ui@0.4.21
| Name | Type | Default | Description |
|---|---|---|---|
idrequired | string | — | Unique identifier. |
labelrequired | string | — | Display text. |
icon | string | — | Iconify icon string. |
href | string | — | Renders as a link instead of a button. |
Usage tips
- The last item renders as plain text (non-clickable) to indicate the current page.
- Use
maxVisibleto keep the breadcrumb compact - middle items collapse into a ”…” dropdown. - Items with
hrefrender as<a>tags; otherwise they render as buttons that callonnavigate. - Set
separatorto"›"or">"for alternative visual styles. - The overflow menu relies on
--z-dropdownfromcomponents.css; define it if you override the theme stack.
CSS styling
.ph-breadcrumb is the stable identification hook for Breadcrumb. Part selectors and --_ph-* properties are internal. Component CSS is scoped and unlayered; Consumer classes remain additive and utility overrides may lose precedence.
The existing sm and md typography is preserved; icons consume the corresponding --ph-comp-icon-* tokens.
Keep the shared component stylesheet and a named Theme imported. Decorative motion respects reduced-motion preferences.