Breadcrumb

free

Breadcrumb keeps nested routes visible so people can move back through the current context.

Preview
Dark
import Breadcrumb from '@/components/ui/Breadcrumb';

const items = [
  { label: 'Sales', href: '/templates/sales-inventory' },
  { label: 'Orders', href: '/templates/sales-inventory/orders' },
  { label: 'SO-1029' },
];

export default function UsageDemo() {
  return (
    <div className="flex justify-center">
      <Breadcrumb items={items} />
    </div>
  );
}

Installation

Add this component with the NateUI CLI.

npx nateui@latest add Breadcrumb

Examples

Basic

Preview
Dark
import Breadcrumb from '@/components/ui/Breadcrumb';

const items = [
  { label: 'Components', href: '/components' },
  { label: 'UI', href: '/components/ui' },
  { label: 'Breadcrumb' },
];

export default function BasicDemo() {
  return (
    <div className="flex justify-center">
      <Breadcrumb items={items} />
    </div>
  );
}

Compound

Preview
Dark
import Breadcrumb from '@/components/ui/Breadcrumb';

const { List, Item, Link, Page, Separator } = Breadcrumb;

export default function CompoundDemo() {
  return (
    <Breadcrumb>
      <List>
        <Item>
          <Link href="/components">Components</Link>
          <Separator />
        </Item>
        <Item>
          <Link href="/components/ui">UI</Link>
          <Separator />
        </Item>
        <Item>
          <Page>Breadcrumb</Page>
        </Item>
      </List>
    </Breadcrumb>
  );
}

Collapsed

Preview
Dark
import Breadcrumb from '@/components/ui/Breadcrumb';

const items = [
  { label: 'Workspace', href: '/workspace' },
  { label: 'Northwind', href: '/workspace/northwind' },
  { label: 'Projects', href: '/workspace/northwind/projects' },
  { label: 'Launch', href: '/workspace/northwind/projects/launch' },
  { label: 'Milestones', href: '/workspace/northwind/projects/launch/milestones' },
  { label: 'Release Review' },
];

export default function CollapsedDemo() {
  return (
    <div className="flex justify-center">
      <Breadcrumb
        items={items}
        maxItems={4}
        itemsBeforeCollapse={1}
        itemsAfterCollapse={2}
        ellipsisLabel="Collapsed pages"
      />
    </div>
  );
}

Separator

Preview
Dark
import { PiCaretRight } from 'react-icons/pi'
import Breadcrumb from '@/components/ui/Breadcrumb';

const items = [
  { label: 'Library', href: '/library' },
  { label: 'Blocks', href: '/library/blocks' },
  { label: 'Tables' },
];

export default function SeparatorDemo() {
  return (
    <div className="grid gap-8">
      <Breadcrumb items={items} separator="/" />
      <Breadcrumb
        items={items}
        separator={<PiCaretRight />}
      />
    </div>
  );
}

Icons

Preview
Dark
import { PiFileText, PiFolder, PiHouse } from 'react-icons/pi'
import Breadcrumb from '@/components/ui/Breadcrumb';

const items = [
  {
    label: 'Home',
    href: '/',
    icon: <PiHouse />,
  },
  {
    label: 'Documents',
    href: '/documents',
    icon: <PiFolder />,
  },
  {
    label: 'Statement.pdf',
    icon: <PiFileText />,
  },
];

export default function IconsDemo() {
  return (
    <div className="flex justify-center">
      <Breadcrumb items={items} />
    </div>
  );
}

Size

Preview
Dark
import Breadcrumb from '@/components/ui/Breadcrumb';

const items = [
  { label: 'Account', href: '/account' },
  { label: 'Security', href: '/account/security' },
  { label: 'Two-factor setup' },
];

export default function SizeDemo() {
  return (
    <div className="grid gap-8">
      <Breadcrumb items={items} size="sm" />
      <Breadcrumb items={items} size="md" />
      <Breadcrumb items={items} size="lg" />
    </div>
  );
}

States

Preview
Dark
import Breadcrumb from '@/components/ui/Breadcrumb';

const items = [
  { label: 'Settings', href: '/settings' },
  {
    label: 'Billing',
    href: '/settings/billing',
    disabled: true,
  },
  {
    label: 'Payment methods',
    href: '/settings/billing/payment-methods',
  },
  {
    label: 'Card ending 4242',
    current: true,
  },
];

export default function StatesDemo() {
  return (
    <div className="flex justify-center">
      <Breadcrumb items={items} />
    </div>
  );
}

Router Adapter

Preview
Dark
import NextLink from 'next/link';
import type { ComponentPropsWithRef } from 'react';
import Breadcrumb from '@/components/ui/Breadcrumb';

type RouterLinkProps = ComponentPropsWithRef<'a'> & {
  href: string;
};

const RouterLink = ({ href, ...props }: RouterLinkProps) => (
  <NextLink href={href} {...props} />
);

const items = [
  { label: 'Templates', href: '/templates' },
  { label: 'CRM', href: '/templates/crm' },
  { label: 'Customer profile' },
];

export default function RouterAdapterDemo() {
  return (
    <div className="flex justify-center">
      <Breadcrumb items={items} renderLink={RouterLink} />
    </div>
  );
}

API

Breadcrumb can render from an items array or from its compound parts. The array form handles current-page detection, disabled crumbs, separators, link adapters, and collapsed middle items.

PropDescriptionTypeDefault
childrenCompound breadcrumb content rendered when items is not provided.ReactNode-
classNameClass names applied to the root nav.string-
classNamesSlot class names for the root-generated list, items, links, page, separator, ellipsis, and icons.BreadcrumbSlotClassNames-
ellipsisLabelScreen-reader label for the collapsed ellipsis item.string'More pages'
itemsData used to render the breadcrumb list automatically.BreadcrumbItemData[]-
itemsAfterCollapseNumber of trailing items kept visible when maxItems collapses the middle.number1
itemsBeforeCollapseNumber of leading items kept visible when maxItems collapses the middle.number1
maxItemsMaximum visible item count before the middle of the trail is replaced by an ellipsis. Values below 3 disable collapsing.number-
refRef forwarded to the root nav.Ref<HTMLElement>-
renderLinkLink renderer used for generated link crumbs unless an individual item supplies its own render.LinkRenderer-
separatorSeparator rendered between generated items. Can be a node or a renderer that receives the item index.ReactNode | BreadcrumbSeparatorRendererChevron based on direction
sizeText size for the breadcrumb. Falls back to ConfigProvider control size.ControlSizeProvider controlSize
...nativePropsNative nav props forwarded to the root element.ComponentPropsWithRef<'nav'>-
PropDescriptionTypeDefault
childrenBreadcrumb item nodes.ReactNode-
classNameClass names applied to the ordered list.string-
refRef forwarded to the ol.Ref<HTMLOListElement>-
...nativePropsNative ordered-list props forwarded to the list.ComponentPropsWithRef<'ol'>-
PropDescriptionTypeDefault
childrenLink, page, separator, or custom breadcrumb content.ReactNode-
classNameClass names applied to the item wrapper.string-
refRef forwarded to the li.Ref<HTMLLIElement>-
...nativePropsNative list-item props forwarded to the item.ComponentPropsWithRef<'li'>-
PropDescriptionTypeDefault
childrenLink label.ReactNode-
classNameClass names applied to the link.string-
hrefDestination URL. Required for link crumbs.string-
iconIcon node rendered before the label.ReactNode-
iconClassNameClass names applied to the icon wrapper.string-
refRef forwarded to the rendered anchor or adapter component.Ref<HTMLAnchorElement>-
renderElement or component used instead of the default anchor.LinkRenderer-
...nativePropsNative anchor props forwarded to the rendered link, excluding href.Omit<ComponentPropsWithRef<'a'>, 'href'>-
PropDescriptionTypeDefault
childrenCurrent page label.ReactNode-
classNameClass names applied to the page label.string-
currentWhether to set aria-current="page" on the label.booleantrue
iconIcon node rendered before the label.ReactNode-
iconClassNameClass names applied to the icon wrapper.string-
refRef forwarded to the span.Ref<HTMLSpanElement>-
...nativePropsNative span props forwarded to the page label.ComponentPropsWithRef<'span'>-
PropDescriptionTypeDefault
childrenCustom separator content. Takes precedence over separator.ReactNode-
classNameClass names applied to the separator.string-
refRef forwarded to the separator span.Ref<HTMLSpanElement>-
separatorSeparator content rendered when children is not provided.ReactNodeDirection-aware chevron
...nativePropsNative span props forwarded to the separator.ComponentPropsWithRef<'span'>-
PropDescriptionTypeDefault
childrenCustom ellipsis content. Defaults to the internal dots icon.ReactNode-
classNameClass names applied to the ellipsis wrapper.string-
labelScreen-reader label for the collapsed crumb control.string'More pages'
refRef forwarded to the ellipsis span.Ref<HTMLSpanElement>-
...nativePropsNative span props forwarded to the ellipsis.ComponentPropsWithRef<'span'>-

Types

type ControlSize = 'sm' | 'md' | 'lg';
 
type BreadcrumbItemData = {
  key?: Key;
  label: ReactNode;
  href?: string;
  icon?: ReactNode;
  disabled?: boolean;
  current?: boolean;
  render?: LinkRenderer;
  target?: ComponentPropsWithRef<'a'>['target'];
  rel?: string;
  title?: string;
  className?: string;
  linkClassName?: string;
  pageClassName?: string;
  separatorClassName?: string;
  onClick?: MouseEventHandler<HTMLAnchorElement>;
};
 
type BreadcrumbSlotClassNames = {
  list?: string;
  item?: string;
  link?: string;
  page?: string;
  separator?: string;
  ellipsis?: string;
  icon?: string;
};
 
type BreadcrumbSeparatorRenderer = (
  props: BreadcrumbSeparatorRenderProps,
) => ReactNode;
 
type BreadcrumbSeparatorRenderProps = {
  index: number;
  isLast: boolean;
};
 
type LinkRenderer = ElementType<LinkRenderProps>;
 
type LinkRenderProps = Omit<ComponentPropsWithRef<'a'>, 'href'> & {
  href: string;
};