Examples
Breadcrumbs
Where the page sits in a hierarchy, each level a link back up. The last item is the current page. Use it on tablets and the web, in file browsers, settings and admin screens; on a phone, a Header with a back button does the job.
import { Breadcrumbs } from 'patine-ui';
Loading…
<Box padding="lg" border radius="lg" gap="sm" style={{ maxWidth: 520 }}> <Breadcrumbs maxItems={4} items={path.map((label, i) => ({ label, icon: i === 0 ? <Icon name="home" size="sm" /> : undefined, onPress: () => setPath(path.slice(0, i + 1)), }))} /> <Heading level={3}>{path[path.length - 1]}</Heading> <Text color="textSecondary">Press a level to go back up to it.</Text> </Box>
Try the props
maxItemsdesign<Breadcrumbs items={path} />
Example: a file browser
A shared drive: opening a folder adds it to the trail, and pressing any level goes back up to it. Long paths fold their middle into a menu.
Loading…
<Box border radius="lg" padding="md" gap="sm" style={{ width: '100%', maxWidth: 480 }}> <Breadcrumbs maxItems={4} items={path.map((label, i) => ({ label, icon: i === 0 ? <Icon name="home" size="sm" /> : undefined, onPress: i < path.length - 1 ? () => setPath(path.slice(0, i + 1)) : undefined, }))} /> <List> {folders.map((name) => ( <ListItem key={name} leading={<Icon name="folder" />} title={name} description={`${DRIVE[name].length} folders`} onPress={() => setPath([...path, name])} /> ))} </List> {folders.length ? null : <Text color="textSecondary">This folder holds files only.</Text>} </Box>
Long paths
Past maxItems, the middle levels fold into …, keeping the first and the last ones. Pressing … unfolds the whole path.
Separator
Each design has its own: a slash on the web and in brand, as shadcn draws it, and a chevron on iOS and Material. separator takes any string or node.
Loading…
<VStack gap="md"> <Breadcrumbs items={items} separator="/" /> <Breadcrumbs items={items} separator="›" /> <Breadcrumbs items={items} separator="→" /> </VStack>
Designs
- brand and web: gray links and slashes, the current page in the text color, as shadcn's Breadcrumb.
- iOS and Material 3: links in the primary color with a chevron, the current page bolder.
Accessibility
- A
navigationlandmark named'Breadcrumb'(accessibilityLabel). Each level is alink; the current page is plain text markedaria-current="page". - Separators are hidden from screen readers. The
…is a link named'Show path'(expandLabel). - Links reach a 44pt touch height on phones and show a focus ring on the web.
Props
Also takes View props.
| Prop | Type | Default | Description |
|---|---|---|---|
items | { label, onPress?, icon? }[] | — | The path from the top to the current page. |
separator | ReactNode | the design's | Between items. |
maxItems | number | no limit | Folds the middle into … past this many. |
accessibilityLabel | string | 'Breadcrumb' | Names the trail. |
expandLabel | string | 'Show path' | The … link's name. |
styles | { item?, current?, separator? } | — | Slot styles. |
theme, design | As every component. |