# Rokkit BreadCrumbs Component > Navigation trail showing the current location within a hierarchy. The BreadCrumbs component displays a path of links showing the user's location in a site hierarchy, with support for custom separators and field mapping. ## Quick Start ```svelte ``` ## Core Concepts ### Path Structure Each breadcrumb item represents a level in the hierarchy: ```javascript const items = [ { label: 'Home', href: '/' }, // Clickable link { label: 'Category', href: '/cat' }, // Clickable link { label: 'Current Page' } // No href = current page ] ``` ### Custom Separator Change the separator between items: ```svelte ``` ### Field Mapping Map your data structure to breadcrumb fields: ```svelte ``` ### Custom Item Rendering Use the `child` snippet for custom rendering: ```svelte {#snippet child(proxy)} {#if proxy.has('href')} {proxy.get('text')} {:else} {proxy.get('text')} {/if} {/snippet} ``` ## Props | Prop | Type | Default | Description | |------|------|---------|-------------| | `items` | `array` | `[]` | Breadcrumb items | | `separator` | `string` | `'/'` | Separator between items | | `fields` | `object` | `{}` | Field mapping configuration | | `child` | `Snippet` | `undefined` | Custom item renderer | | `class` | `string` | `''` | CSS class names | ## Field Mapping | Field | Default | Description | |-------|---------|-------------| | `text` | `'text'` | Display text | | `href` | `'href'` | Link URL | | `icon` | `'icon'` | Optional icon | ## Component Structure ```
├──
// First item │ └── // Rendered via Item component ├── // Separator ├──
// Second item │ └── ├── └──
// Last item (current) └──
``` ## Data Attributes for Styling | Attribute | Element | Purpose | |-----------|---------|---------| | `data-crumb-root` | Root | Main container | | `data-crumb-item` | div | Individual crumb | | `data-crumb-separator` | Icon | Separator element | | `.is-selected` | Last item | Current page indicator | ### Styling Example ```css [data-crumb-root] { display: flex; align-items: center; gap: 8px; font-size: 0.875rem; } [data-crumb-item] { display: flex; align-items: center; } [data-crumb-item] a { color: var(--primary-600); text-decoration: none; } [data-crumb-item] a:hover { text-decoration: underline; } [data-crumb-item].is-selected { color: var(--text-primary); font-weight: 500; } [data-crumb-separator] { color: var(--text-muted); font-size: 0.75rem; } ``` ## Import ```javascript // Named import import { BreadCrumbs } from '@rokkit/ui' // Default import import BreadCrumbs from '@rokkit/ui/bread-crumbs' ``` ## TypeScript Types ```typescript interface BreadCrumbsProps { items?: BreadCrumbItem[] separator?: string fields?: FieldMapping child?: Snippet<[Proxy]> class?: string } interface BreadCrumbItem { text?: string href?: string icon?: string [key: string]: any } ``` ## Examples ### Basic Breadcrumbs ```svelte ``` ### With Icons ```svelte ``` ### Arrow Separator ```svelte ``` ### Chevron Separator ```svelte ``` ### Dynamic Path from URL ```svelte ``` ### With Custom Rendering ```svelte {#snippet child(proxy)}
{#if proxy.has('icon')} {/if} {#if proxy.has('href')} {proxy.get('text')} {:else} {proxy.get('text')} {/if} {#if proxy.value.count} ({proxy.value.count}) {/if}
{/snippet}
``` ### E-commerce Path ```svelte ``` ### Truncated Breadcrumbs ```svelte ``` ## Accessibility - Wrap in `