Navigation

Breadcrumb

Display a hierarchical navigation trail showing the user's current location within the app. Supports icons, custom separators, disabled items, and fully customizable rendering via snippets.

Playground

Experiment with different props in real-time.

Basic Usage

Pass an array of items to the Breadcrumb. The last item without an href is treated as the current page.

<script lang="ts">
  import { Breadcrumb } from 'sv5ui';
  import type { BreadcrumbItem } from 'sv5ui';

  const items: BreadcrumbItem[] = [
    { label: 'Home', href: '/' },
    { label: 'Components', href: '/docs/components' },
    { label: 'Breadcrumb' }
  ];
</script>

<Breadcrumb {items} />

With Icons

Add an icon property to each item to display a leading icon using Iconify names.

<script lang="ts">
  import { Breadcrumb } from 'sv5ui';
  import type { BreadcrumbItem } from 'sv5ui';

  const items: BreadcrumbItem[] = [
    { label: 'Home', href: '/', icon: 'lucide:house' },
    { label: 'Settings', href: '/settings', icon: 'lucide:settings' },
    { label: 'Profile', icon: 'lucide:user' }
  ];
</script>

<Breadcrumb {items} />

Custom Separator Icon

Change the separator between items using the separatorIcon prop.

<Breadcrumb {items} separatorIcon="lucide:chevron-right" />
<Breadcrumb {items} separatorIcon="lucide:slash" />
<Breadcrumb {items} separatorIcon="lucide:dot" />
<Breadcrumb {items} separatorIcon="lucide:minus" />

Disabled Items

Set disabled: true on an item to prevent navigation and apply disabled styling.

<script lang="ts">
  import { Breadcrumb } from 'sv5ui';
  import type { BreadcrumbItem } from 'sv5ui';

  const items: BreadcrumbItem[] = [
    { label: 'Home', href: '/' },
    { label: 'Archived', href: '/archived', disabled: true },
    { label: 'Detail' }
  ];
</script>

<Breadcrumb {items} />

Custom Separator Snippet

Use the separator snippet to fully replace the default separator icon with custom markup.

<Breadcrumb {items}>
  {#snippet separator()}
    <span class="text-on-surface/30 mx-1">/</span>
  {/snippet}
</Breadcrumb>

Custom Item Snippet

Use the item snippet to fully customize how each breadcrumb item is rendered.

<Breadcrumb {items}>
  {#snippet item({ item, index, active })}
    <span
      class="rounded-full px-3 py-1 text-sm font-medium
        {active
          ? 'bg-primary text-on-primary'
          : 'bg-surface-container text-on-surface/60 hover:bg-surface-container-high'}"
    >
      {item.label}
    </span>
  {/snippet}
</Breadcrumb>

UI Slots

Use the ui prop to override classes on specific internal elements of the Breadcrumb.

SlotDescription
rootRoot nav element — controls wrapper styles
listOrdered list element — controls list layout and spacing
itemList item element — controls individual breadcrumb item wrapper
linkAnchor/span element — controls link appearance and hover states
linkLeadingIconIcon before label inside link — controls icon size and color
linkLabelText label inside link — controls font and text styles
separatorSeparator wrapper — controls spacing around the separator
separatorIconSeparator icon element — controls separator icon size and color
<Breadcrumb
  {items}
  ui={{
    root: 'bg-surface-container rounded-lg px-4 py-2',
    link: 'font-semibold',
    separatorIcon: 'text-primary'
  }}
/>

Snippets

Use snippets to fully replace the default rendering of items or separators with custom markup.

SnippetParametersDescription
item{ item, index, active }Custom render for each breadcrumb item — replaces the default link/label rendering
separator-Custom separator between items — replaces the default separator icon

Props

PropTypeDefault
askeyof HTMLElementTagNameMap'nav'
itemsBreadcrumbItem[]-
separatorIconstring'lucide:chevron-right'
itemSnippet<[{ item, index, active }]>-
separatorSnippet-
classstring-
uiRecord<Slot, Class>-

BreadcrumbItem Props

Each object in the items array accepts the following properties.

PropTypeDefault
labelstring-
hrefstring-
iconstring-
disabledbooleanfalse
classstring-