@akhatmirzo/ui

Breadcrumb

A trail that shows where the user is in the site hierarchy — with collapsing, an overflow menu and Next.js Link support.

Import

import { Breadcrumb } from '@akhatmirzo/ui';

When to use

  • Deep hierarchies — catalog → category → product, settings → account → security. Users get back to a higher level in one click.
  • Place it above the page title, before the content.
  • Skip it on flat sites — "Home → Current" alone adds little.
  • Not for steps. To show a sequential process, use Stepper.

Items

items is a list of { label, href?, icon?, onClick? }. The last item is the current page: it is not a link and gets aria-current="page". An item with onClick but no href renders as a button.

Collapsing

When there are more than maxItems: first + … + the last maxItems - 2 (at least 1). Clicking … opens the hidden pages in a DropdownMenu.

On phones (< 640px) the trail automatically collapses to … + parent + current. This is done with a CSS breakpoint, so there is no SSR hydration mismatch. Long labels are truncated (links at 20ch, the current page at 32ch).

Separator and size

separator accepts any ReactNode (default — a › chevron). size="sm" uses text-xs.

renderLink replaces <a> with your own link component. It is used inside the overflow menu too.

import Link from 'next/link';
import { Breadcrumb } from '@akhatmirzo/ui';

<Breadcrumb
  items={[
    { label: 'Home', href: '/' },
    { label: 'Products', href: '/products' },
    { label: 'iPhone 17' },
  ]}
  renderLink={(props) => <Link {...props} />}
/>;

Props

Other <nav> attributes are passed through.

PropTypeDefaultDescription
itemsrequired{ label: ReactNode; href?: string; icon?: ReactNode; onClick?: (event) => void }[]—Trail items; the last one is the current page
separatorReactNode—Separator (default — `›` chevron)
maxItemsnumber—When exceeded: first + `…` + the last ones; hidden items go to a menu
renderLink(props: { href, className, children, onClick }) => ReactNode—Custom link component such as Next `Link`
size'sm' | 'md''md'`text-xs` / `text-sm`
labels{ nav?: string; more?: string }—Defaults: "Sahifa yo'li", "Yashirilgan sahifalar"

Data attributes

AttributeWhereValue
data-sizenavsm · md
data-slotpartsbreadcrumb-item · breadcrumb-ellipsis · breadcrumb-separator
data-viewport… itemdesktop · mobile

Accessibility

  • Structure. <nav aria-label="Sahifa yo'li"> wraps an ordered <ol> list.
  • The current page is not a link and is marked with aria-current="page".
  • Separators are decorative — aria-hidden, screen readers skip them.
  • The … button has aria-label="Yashirilgan sahifalar" and aria-haspopup="menu". Enter / Space opens it, ↑ ↓ move through items, Esc closes it and returns focus to the button.
  • The phone layout hides items with CSS (display: none), so screen readers only read what is visible.

On this page