Directory
- Welcome
Breadcrumb Component
Create clear navigation paths that help users understand their location within your site’s hierarchy. The Breadcrumb component automatically transforms URLs into readable navigation trails and handles long paths elegantly.
Key Features
-
Automatic Path Generation: Converts URLs into readable navigation trails
-
Smart Truncation: Handles long paths with dropdown menus
-
Customizable Labels: Support for custom navigation text
-
Responsive Design: Adapts to different screen sizes
Quick Start
<Breadcrumb href="/docs/components/breadcrumb" />
Features
Custom Navigation Labels
<Breadcrumb items={[ { label: 'Documentation', href: '/docs/' }, { label: 'Components', href: '/docs/components/' }, { label: 'Navigation', href: '/docs/components/breadcrumb/' }, ]}/>
Path Length Control
<Breadcrumb href="/docs/components/carousel/card/" maxItems={4}/>
Text Truncation
<Breadcrumb items={[ { label: 'Very Long Category Name', href: '/category' }, { label: 'Product Details', href: '/category/product' }, ]} maxTextLength={10}/>
Breadcrumb Component Props API
Prop | Type | Default | Description |
---|---|---|---|
buttonProps | ComponentProps<typeof Button> | Props for the buttons | |
href | string | URL path to generate breadcrumbs from | |
items | BreadcrumbItem[] | [] | Custom navigation items |
maxItems | number | Maximum number of visible items | |
maxTextLength | number | Maximum length for item labels | |
showHome | boolean | true | Show/hide home link |
Breadcrumb Functions API
The breadcrumb component exposes several methods for programmatic control, allowing what would otherwise be a static component to be dynamic:
Function | Type | Description |
---|---|---|
set: path | string | BreadcrumbItem[] | Set the breadcrumb path |
set: showHome | boolean | Toggle home link visibility |
set: maxItems | number | Set maximum items before collapsing |
set: maxTextLength | number | Set maximum text length before truncating |
type BreadcrumbItem = { label: string; href: string;};
Best Practices
-
URL Structure
- Use clear, hierarchical URLs
- Keep URL segments concise
- Use consistent naming conventions
-
Label Usage
- Keep labels short and descriptive
- Use consistent terminology
- Consider mobile screen constraints
Common Applications
Limited Time Launch Sale
Ready to improve your site’s navigation? Get our AstroJS starter template now and implement intuitive breadcrumb trails in minutes.
GET 60% OFF!