Breadcrumb

Displays the path to the current resource using a hierarchy of links.

Installation

The CLI is not yet available. For now, manually copy the component source into your project.

rust-shadcn-ui add breadcrumb

Usage

use yew::prelude::*;

use crate::components::ui::badge::{Badge, BadgeVariant};

#[component]
fn Usage() -> impl IntoView {
    view! {
        <Breadcrumb>
            <BreadcrumbList>
                <BreadcrumbItem>
                    <BreadcrumbLink href="/">{"Home"}</BreadcrumbLink>
                </BreadcrumbItem>
                <BreadcrumbSeparator />
                <BreadcrumbItem>
                    <BreadcrumbLink href="/components">{"Components"}</BreadcrumbLink>
                </BreadcrumbItem>
                <BreadcrumbSeparator />
                <BreadcrumbItem>
                    <BreadcrumbPage>{"Breadcrumb"}</BreadcrumbPage>
                </BreadcrumbItem>
            </BreadcrumbList>
        </Breadcrumb>
    }
}

Examples

Custom Separator

Use a custom component as children for <BreadcrumbSeparator /> to create a custom separator.

You can compose <BreadcrumbItem /> with a <DropdownMenu /> to create a dropdown in the breadcrumb.

Collapsed

A <BreadcrumbEllipsis /> component is provided to show a collapsed state when the breadcrumb is too long.

To use a custom link component from your routing library, you can use the as_child prop on <BreadcrumbLink />.

Responsive

Here's an example of a responsive breadcrumb that composes <BreadcrumbItem /> with <BreadcrumbEllipsis />, <DropdownMenu />, and <Drawer />.

It displays a dropdown on desktop and a drawer on mobile.

See Also