Theme
Customize appearance
Components
Breadcrumb
Show the hierarchy leading to the current page.
View component source ↗Preview
A minimal example to get started.
Installation
Install this component and its dependencies in a project initialized with shadcn.
pnpm dlx shadcn@latest add https://ui.hyunjoon.net/r/breadcrumb.jsonUsage
This is the basic example. Use the Code tab above for the selected example. Adjust import aliases to match your project.
import {
Breadcrumb,
BreadcrumbList,
BreadcrumbItem,
BreadcrumbLink,
BreadcrumbSeparator,
BreadcrumbPage,
} from "@/components/ui/breadcrumb";
export default function Example() {
return (
<Breadcrumb>
<BreadcrumbList>
<BreadcrumbItem>
<BreadcrumbLink href="/docs">Docs</BreadcrumbLink>
</BreadcrumbItem>
<BreadcrumbSeparator />
<BreadcrumbItem>
<BreadcrumbPage>Components</BreadcrumbPage>
</BreadcrumbItem>
</BreadcrumbList>
</Breadcrumb>
);
}
API reference
Derived from the installed component types. Native DOM props are also supported where applicable. A dash means no explicit default is documented. Some props depend on the selected mode.
Breadcrumb
| Prop | Type | Default | Description |
|---|---|---|---|
ref | React.Ref<HTMLElement> | undefinedReact.Ref<HTMLElement> | undefined | — | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). |
defaultChecked | boolean | undefinedboolean | undefined | — | Initial checked state for an uncontrolled control. |
defaultValue | string | number | readonly string[] | undefinedstring | number | readonly string[] | undefined | — | Initial value for an uncontrolled component. |
className | string | undefinedstring | undefined | — | Additional CSS classes merged with the component styles. |
id | string | undefinedstring | undefined | — | Unique identifier used to associate labels and descriptions. |
children | React.ReactNodeReact.ReactNode | — | Content rendered inside this component. |
onFocus | React.FocusEventHandler<HTMLElement> | undefinedReact.FocusEventHandler<HTMLElement> | undefined | — | Called when the control receives focus. |
onBlur | React.FocusEventHandler<HTMLElement> | undefinedReact.FocusEventHandler<HTMLElement> | undefined | — | Called when the control loses focus. |
onChange | React.ChangeEventHandler<HTMLElement, Element> | undefinedReact.ChangeEventHandler<HTMLElement, Element> | undefined | — | Called when the underlying form control changes; inspect the event for its value. |
onKeyDown | React.KeyboardEventHandler<HTMLElement> | undefinedReact.KeyboardEventHandler<HTMLElement> | undefined | — | Called when a key is pressed while this element is focused. |
onClick | React.MouseEventHandler<HTMLElement> | undefinedReact.MouseEventHandler<HTMLElement> | undefined | — | Called when the element is activated. |
BreadcrumbList
| Prop | Type | Default | Description |
|---|---|---|---|
ref | React.Ref<HTMLOListElement> | undefinedReact.Ref<HTMLOListElement> | undefined | — | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). |
type | "a" | "i" | "1" | "A" | "I" | undefined"a" | "i" | "1" | "A" | "I" | undefined | — | The native input or button behavior. |
defaultChecked | boolean | undefinedboolean | undefined | — | Initial checked state for an uncontrolled control. |
defaultValue | string | number | readonly string[] | undefinedstring | number | readonly string[] | undefined | — | Initial value for an uncontrolled component. |
className | string | undefinedstring | undefined | — | Additional CSS classes merged with the component styles. |
id | string | undefinedstring | undefined | — | Unique identifier used to associate labels and descriptions. |
children | React.ReactNodeReact.ReactNode | — | Content rendered inside this component. |
onFocus | React.FocusEventHandler<HTMLOListElement> | undefinedReact.FocusEventHandler<HTMLOListElement> | undefined | — | Called when the control receives focus. |
onBlur | React.FocusEventHandler<HTMLOListElement> | undefinedReact.FocusEventHandler<HTMLOListElement> | undefined | — | Called when the control loses focus. |
onChange | React.ChangeEventHandler<HTMLOListElement, Element> | undefinedReact.ChangeEventHandler<HTMLOListElement, Element> | undefined | — | Called when the underlying form control changes; inspect the event for its value. |
onKeyDown | React.KeyboardEventHandler<HTMLOListElement> | undefinedReact.KeyboardEventHandler<HTMLOListElement> | undefined | — | Called when a key is pressed while this element is focused. |
onClick | React.MouseEventHandler<HTMLOListElement> | undefinedReact.MouseEventHandler<HTMLOListElement> | undefined | — | Called when the element is activated. |
BreadcrumbItem
| Prop | Type | Default | Description |
|---|---|---|---|
ref | React.Ref<HTMLLIElement> | undefinedReact.Ref<HTMLLIElement> | undefined | — | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). |
value | string | number | readonly string[] | undefinedstring | number | readonly string[] | undefined | — | The current value when controlled by the application. |
defaultChecked | boolean | undefinedboolean | undefined | — | Initial checked state for an uncontrolled control. |
defaultValue | string | number | readonly string[] | undefinedstring | number | readonly string[] | undefined | — | Initial value for an uncontrolled component. |
className | string | undefinedstring | undefined | — | Additional CSS classes merged with the component styles. |
id | string | undefinedstring | undefined | — | Unique identifier used to associate labels and descriptions. |
children | React.ReactNodeReact.ReactNode | — | Content rendered inside this component. |
onFocus | React.FocusEventHandler<HTMLLIElement> | undefinedReact.FocusEventHandler<HTMLLIElement> | undefined | — | Called when the control receives focus. |
onBlur | React.FocusEventHandler<HTMLLIElement> | undefinedReact.FocusEventHandler<HTMLLIElement> | undefined | — | Called when the control loses focus. |
onChange | React.ChangeEventHandler<HTMLLIElement, Element> | undefinedReact.ChangeEventHandler<HTMLLIElement, Element> | undefined | — | Called when the underlying form control changes; inspect the event for its value. |
onKeyDown | React.KeyboardEventHandler<HTMLLIElement> | undefinedReact.KeyboardEventHandler<HTMLLIElement> | undefined | — | Called when a key is pressed while this element is focused. |
onClick | React.MouseEventHandler<HTMLLIElement> | undefinedReact.MouseEventHandler<HTMLLIElement> | undefined | — | Called when the element is activated. |
BreadcrumbLink
| Prop | Type | Default | Description |
|---|---|---|---|
ref | React.Ref<HTMLAnchorElement> | undefinedReact.Ref<HTMLAnchorElement> | undefined | — | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). |
href | string | undefinedstring | undefined | — | Destination URL for the link. |
target | React.HTMLAttributeAnchorTarget | undefinedReact.HTMLAttributeAnchorTarget | undefined | — | Browsing context in which the link opens. |
type | string | undefinedstring | undefined | — | The native input or button behavior. |
defaultChecked | boolean | undefinedboolean | undefined | — | Initial checked state for an uncontrolled control. |
defaultValue | string | number | readonly string[] | undefinedstring | number | readonly string[] | undefined | — | Initial value for an uncontrolled component. |
className | string | undefinedstring | undefined | — | Additional CSS classes merged with the component styles. |
id | string | undefinedstring | undefined | — | Unique identifier used to associate labels and descriptions. |
children | React.ReactNodeReact.ReactNode | — | Content rendered inside this component. |
onFocus | React.FocusEventHandler<HTMLAnchorElement> | undefinedReact.FocusEventHandler<HTMLAnchorElement> | undefined | — | Called when the control receives focus. |
onBlur | React.FocusEventHandler<HTMLAnchorElement> | undefinedReact.FocusEventHandler<HTMLAnchorElement> | undefined | — | Called when the control loses focus. |
onChange | React.ChangeEventHandler<HTMLAnchorElement, Element> | undefinedReact.ChangeEventHandler<HTMLAnchorElement, Element> | undefined | — | Called when the underlying form control changes; inspect the event for its value. |
onKeyDown | React.KeyboardEventHandler<HTMLAnchorElement> | undefinedReact.KeyboardEventHandler<HTMLAnchorElement> | undefined | — | Called when a key is pressed while this element is focused. |
onClick | React.MouseEventHandler<HTMLAnchorElement> | undefinedReact.MouseEventHandler<HTMLAnchorElement> | undefined | — | Called when the element is activated. |
render | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn…React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, {}> | undefined | — | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
BreadcrumbPage
| Prop | Type | Default | Description |
|---|---|---|---|
ref | React.Ref<HTMLSpanElement> | undefinedReact.Ref<HTMLSpanElement> | undefined | — | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). |
defaultChecked | boolean | undefinedboolean | undefined | — | Initial checked state for an uncontrolled control. |
defaultValue | string | number | readonly string[] | undefinedstring | number | readonly string[] | undefined | — | Initial value for an uncontrolled component. |
className | string | undefinedstring | undefined | — | Additional CSS classes merged with the component styles. |
id | string | undefinedstring | undefined | — | Unique identifier used to associate labels and descriptions. |
children | React.ReactNodeReact.ReactNode | — | Content rendered inside this component. |
onFocus | React.FocusEventHandler<HTMLSpanElement> | undefinedReact.FocusEventHandler<HTMLSpanElement> | undefined | — | Called when the control receives focus. |
onBlur | React.FocusEventHandler<HTMLSpanElement> | undefinedReact.FocusEventHandler<HTMLSpanElement> | undefined | — | Called when the control loses focus. |
onChange | React.ChangeEventHandler<HTMLSpanElement, Element> | undefinedReact.ChangeEventHandler<HTMLSpanElement, Element> | undefined | — | Called when the underlying form control changes; inspect the event for its value. |
onKeyDown | React.KeyboardEventHandler<HTMLSpanElement> | undefinedReact.KeyboardEventHandler<HTMLSpanElement> | undefined | — | Called when a key is pressed while this element is focused. |
onClick | React.MouseEventHandler<HTMLSpanElement> | undefinedReact.MouseEventHandler<HTMLSpanElement> | undefined | — | Called when the element is activated. |
BreadcrumbSeparator
| Prop | Type | Default | Description |
|---|---|---|---|
ref | React.Ref<HTMLLIElement> | undefinedReact.Ref<HTMLLIElement> | undefined | — | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). |
value | string | number | readonly string[] | undefinedstring | number | readonly string[] | undefined | — | The current value when controlled by the application. |
defaultChecked | boolean | undefinedboolean | undefined | — | Initial checked state for an uncontrolled control. |
defaultValue | string | number | readonly string[] | undefinedstring | number | readonly string[] | undefined | — | Initial value for an uncontrolled component. |
className | string | undefinedstring | undefined | — | Additional CSS classes merged with the component styles. |
id | string | undefinedstring | undefined | — | Unique identifier used to associate labels and descriptions. |
children | React.ReactNodeReact.ReactNode | — | Content rendered inside this component. |
onFocus | React.FocusEventHandler<HTMLLIElement> | undefinedReact.FocusEventHandler<HTMLLIElement> | undefined | — | Called when the control receives focus. |
onBlur | React.FocusEventHandler<HTMLLIElement> | undefinedReact.FocusEventHandler<HTMLLIElement> | undefined | — | Called when the control loses focus. |
onChange | React.ChangeEventHandler<HTMLLIElement, Element> | undefinedReact.ChangeEventHandler<HTMLLIElement, Element> | undefined | — | Called when the underlying form control changes; inspect the event for its value. |
onKeyDown | React.KeyboardEventHandler<HTMLLIElement> | undefinedReact.KeyboardEventHandler<HTMLLIElement> | undefined | — | Called when a key is pressed while this element is focused. |
onClick | React.MouseEventHandler<HTMLLIElement> | undefinedReact.MouseEventHandler<HTMLLIElement> | undefined | — | Called when the element is activated. |
BreadcrumbEllipsis
| Prop | Type | Default | Description |
|---|---|---|---|
ref | React.Ref<HTMLSpanElement> | undefinedReact.Ref<HTMLSpanElement> | undefined | — | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). |
defaultChecked | boolean | undefinedboolean | undefined | — | Initial checked state for an uncontrolled control. |
defaultValue | string | number | readonly string[] | undefinedstring | number | readonly string[] | undefined | — | Initial value for an uncontrolled component. |
className | string | undefinedstring | undefined | — | Additional CSS classes merged with the component styles. |
id | string | undefinedstring | undefined | — | Unique identifier used to associate labels and descriptions. |
children | React.ReactNodeReact.ReactNode | — | Content rendered inside this component. |
onFocus | React.FocusEventHandler<HTMLSpanElement> | undefinedReact.FocusEventHandler<HTMLSpanElement> | undefined | — | Called when the control receives focus. |
onBlur | React.FocusEventHandler<HTMLSpanElement> | undefinedReact.FocusEventHandler<HTMLSpanElement> | undefined | — | Called when the control loses focus. |
onChange | React.ChangeEventHandler<HTMLSpanElement, Element> | undefinedReact.ChangeEventHandler<HTMLSpanElement, Element> | undefined | — | Called when the underlying form control changes; inspect the event for its value. |
onKeyDown | React.KeyboardEventHandler<HTMLSpanElement> | undefinedReact.KeyboardEventHandler<HTMLSpanElement> | undefined | — | Called when a key is pressed while this element is focused. |
onClick | React.MouseEventHandler<HTMLSpanElement> | undefinedReact.MouseEventHandler<HTMLSpanElement> | undefined | — | Called when the element is activated. |
Usage notes
Link earlier locations and mark the final item as the current page. Keep this hierarchy separate from primary navigation.