Breadcrumbs

Breadcrumbs display a hierarchy of links to the current page or resource in an application.

Theme 
  1. Home
  2. React Aria
  3. Breadcrumbs
isDisabled 
Example
Breadcrumbs.tsx
Breadcrumbs.css
import {Breadcrumbs, Breadcrumb} from './Breadcrumbs';

<Breadcrumbs>
  <Breadcrumb href="#">Home</Breadcrumb>
  <Breadcrumb href="#">React Aria</Breadcrumb>
  <Breadcrumb>Breadcrumbs</Breadcrumb>
</Breadcrumbs>

Content

Breadcrumbs follows the Collection Components API, accepting both static and dynamic collections. This example shows a dynamic collection, passing a list of objects to the items prop, and a function to render the children. The onAction event is called when a user presses a breadcrumb.

  1. Home
  2. Trendy
  3. March 2022 Assets
import type {Key} from 'react-aria-components';
import {Breadcrumbs, Breadcrumb} from './Breadcrumbs';
import {useState} from 'react';

function Example() {
  let [breadcrumbs, setBreadcrumbs] = useState([
    {id: 1, label: 'Home'},
    {id: 2, label: 'Trendy'},
    {id: 3, label: 'March 2022 Assets'}
  ]);

  let navigate = (id: Key) => {
    let i = breadcrumbs.findIndex(item => item.id === id);
    setBreadcrumbs(breadcrumbs.slice(0, i + 1));
  };

  return (
    <Breadcrumbs items={breadcrumbs} onAction={navigate}>
      {item => <Breadcrumb>{item.label}</Breadcrumb>}
    </Breadcrumbs>
  );
}

API

Shows a breadcrumbs component with labels pointing to its parts, including the navigation container, breadcrumb items, separators, and current page elements.TrendSub ItemJanuary 2019 AssetsBreadcrumb itemSeparatorCurrent pageNavigation
<Breadcrumbs>
  <Breadcrumb>
    <Link />
  </Breadcrumb>
</Breadcrumbs>
NameType
isDisabledboolean
Whether the breadcrumbs are disabled.
childrenReactNode(item: T) => ReactNode
The contents of the collection.
itemsIterable<T>
Item objects in the collection.
dependenciesReadonlyArray<any>
Values that should invalidate the item cache when using dynamic collections.

Default className: react-aria-Breadcrumbs

NameType
idKey
A unique id for the breadcrumb, which will be passed to onAction when the breadcrumb is pressed.
children<>
The children of the component. A function may be provided to alter the children based on component state.

Default className: react-aria-Breadcrumb

Render PropCSS Selector
isCurrentCSS Selector: [data-current]
Whether the breadcrumb is for the current page.
isDisabledCSS Selector: [data-disabled]
Whether the breadcrumb is disabled.