import {Meta} from '@storybook/blocks';
import {Canvas} from '@storybook/addon-docs';
import * as BreadcrumbStories from './Breadcrumbs.stories';
import {Hint} from '../../../components';

<Meta title="Components/Breadcrumbs"/>

<Hint>Components</Hint>

# Breadcrumbs

The breadcrumbs component helps users to understand where they are within a website’s structure and move between levels.

<Canvas of={BreadcrumbStories.primary}/>

## When to use this component

Use the breadcrumbs component when you need to help users understand and move between the multiple levels of a website.

## When not to use this component

Do not use the breadcrumbs component on websites with a flat structure, or to show progress through a linear journey or transaction.

If you’re using other navigational elements on the page, such as a sidebar, consider whether your users need the additional support of breadcrumbs.

## How it works

Always place breadcrumbs at the top of a page, before the `<main>` element. Placing them here means that the ‘Skip to main content’ link allows the user to skip all navigation links, including breadcrumbs.

The breadcrumb should start with your ‘home’ page and end with the parent section of the current page.

<Canvas of={BreadcrumbStories.primary}/>

## Collapsing breadcrumbs on mobile devices

If you have long breadcrumbs you can configure the component to only show the first and last items on mobile devices.

To do this, add the prop `collapseOnMobile` to the `Breadcrumbs` component as shown in this example.

<Canvas of={BreadcrumbStories.collapseOnMobile}/>
