--- productId: material-ui title: React Breadcrumbs component components: Breadcrumbs, Link, Typography githubLabel: 'scope: breadcrumbs' waiAria: https://www.w3.org/WAI/ARIA/apg/patterns/breadcrumb/ githubSource: packages/mui-material/src/Breadcrumbs --- # Breadcrumbs A breadcrumbs is a list of links that help visualize a page's location within a site's hierarchical structure, it allows navigation up to any of the ancestors. ## Basic breadcrumbs ```tsx import * as React from 'react'; import Typography from '@mui/material/Typography'; import Breadcrumbs from '@mui/material/Breadcrumbs'; import Link from '@mui/material/Link'; function handleClick(event: React.MouseEvent) { event.preventDefault(); console.info('You clicked a breadcrumb.'); } export default function BasicBreadcrumbs() { return (
MUI Core Breadcrumbs
); } ``` ## Active last breadcrumb Keep the last breadcrumb interactive. ```tsx import * as React from 'react'; import Breadcrumbs from '@mui/material/Breadcrumbs'; import Link from '@mui/material/Link'; function handleClick(event: React.MouseEvent) { event.preventDefault(); console.info('You clicked a breadcrumb.'); } export default function ActiveLastBreadcrumb() { return (
MUI Core Breadcrumbs
); } ``` ## Custom separator In the following examples, we are using two string separators and an SVG icon. ```tsx import * as React from 'react'; import Breadcrumbs from '@mui/material/Breadcrumbs'; import Typography from '@mui/material/Typography'; import Link from '@mui/material/Link'; import Stack from '@mui/material/Stack'; import NavigateNextIcon from '@mui/icons-material/NavigateNext'; function handleClick(event: React.MouseEvent) { event.preventDefault(); console.info('You clicked a breadcrumb.'); } export default function CustomSeparator() { const breadcrumbs = [ MUI , Core , Breadcrumb , ]; return ( {breadcrumbs} {breadcrumbs} } aria-label="breadcrumb" > {breadcrumbs} ); } ``` ## Breadcrumbs with icons ```tsx import * as React from 'react'; import Typography from '@mui/material/Typography'; import Breadcrumbs from '@mui/material/Breadcrumbs'; import Link from '@mui/material/Link'; import HomeIcon from '@mui/icons-material/Home'; import WhatshotIcon from '@mui/icons-material/Whatshot'; import GrainIcon from '@mui/icons-material/Grain'; function handleClick(event: React.MouseEvent) { event.preventDefault(); console.info('You clicked a breadcrumb.'); } export default function IconBreadcrumbs() { return (
MUI Core Breadcrumb
); } ``` ## Collapsed breadcrumbs ```tsx import * as React from 'react'; import Breadcrumbs from '@mui/material/Breadcrumbs'; import Typography from '@mui/material/Typography'; import Link from '@mui/material/Link'; function handleClick(event: React.MouseEvent) { event.preventDefault(); console.info('You clicked a breadcrumb.'); } export default function CollapsedBreadcrumbs() { return (
Home Catalog Accessories New Collection Belts
); } ``` ## Condensed with menu As an alternative, consider adding a Menu component to display the condensed links in a dropdown list: ```tsx import * as React from 'react'; import Breadcrumbs from '@mui/material/Breadcrumbs'; import Link from '@mui/material/Link'; import Menu from '@mui/material/Menu'; import MenuItem from '@mui/material/MenuItem'; import IconButton from '@mui/material/IconButton'; import MoreHorizIcon from '@mui/icons-material/MoreHoriz'; export default function CondensedWithMenu() { const [anchorEl, setAnchorEl] = React.useState(null); const open = Boolean(anchorEl); const handleClick = (event: React.MouseEvent | null) => { if (event) { setAnchorEl(event.currentTarget); } }; const handleClose = () => { setAnchorEl(null); }; return ( Breadcrumb 2 Breadcrumb 3 Breadcrumb 4 Breadcrumb 1 Breadcrumb 5 Breadcrumb 6 ); } ``` ## Customization Here is an example of customizing the component. You can learn more about this in the [overrides documentation page](/material-ui/customization/how-to-customize/). ```tsx import * as React from 'react'; import { emphasize, styled } from '@mui/material/styles'; import Breadcrumbs from '@mui/material/Breadcrumbs'; import Chip from '@mui/material/Chip'; import HomeIcon from '@mui/icons-material/Home'; import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; const StyledBreadcrumb = styled(Chip)(({ theme }) => { return { backgroundColor: theme.palette.grey[100], height: theme.spacing(3), color: (theme.vars || theme).palette.text.primary, fontWeight: theme.typography.fontWeightRegular, '&:hover, &:focus': { backgroundColor: emphasize(theme.palette.grey[100], 0.06), ...theme.applyStyles('dark', { backgroundColor: emphasize(theme.palette.grey[800], 0.06), }), }, '&:active': { boxShadow: theme.shadows[1], backgroundColor: emphasize(theme.palette.grey[100], 0.12), ...theme.applyStyles('dark', { backgroundColor: emphasize(theme.palette.grey[800], 0.12), }), }, ...theme.applyStyles('dark', { backgroundColor: theme.palette.grey[800], }), }; }) as typeof Chip; // TypeScript only: need a type cast here because https://github.com/Microsoft/TypeScript/issues/26591 function handleClick(event: React.MouseEvent) { event.preventDefault(); console.info('You clicked a breadcrumb.'); } export default function CustomizedBreadcrumbs() { return (
} /> } onDelete={handleClick} />
); } ``` ## Integration with react-router ```tsx import * as React from 'react'; import Box from '@mui/material/Box'; import List from '@mui/material/List'; import Link, { LinkProps } from '@mui/material/Link'; import { ListItemProps } from '@mui/material/ListItem'; import ListItemButton from '@mui/material/ListItemButton'; import Collapse from '@mui/material/Collapse'; import ListItemText from '@mui/material/ListItemText'; import Typography from '@mui/material/Typography'; import ExpandLess from '@mui/icons-material/ExpandLess'; import ExpandMore from '@mui/icons-material/ExpandMore'; import Breadcrumbs from '@mui/material/Breadcrumbs'; import { Link as RouterLink, Route, Routes, MemoryRouter, useLocation, } from 'react-router'; interface ListItemLinkProps extends ListItemProps { to: string; open?: boolean; } const breadcrumbNameMap: { [key: string]: string } = { '/inbox': 'Inbox', '/inbox/important': 'Important', '/trash': 'Trash', '/spam': 'Spam', '/drafts': 'Drafts', }; function ListItemLink(props: ListItemLinkProps) { const { to, open, ...other } = props; const primary = breadcrumbNameMap[to]; let icon = null; if (open != null) { icon = open ? : ; } return (
  • {icon}
  • ); } interface LinkRouterProps extends LinkProps { to: string; replace?: boolean; } function LinkRouter(props: LinkRouterProps) { return ; } function Page() { const location = useLocation(); const pathnames = location.pathname.split('/').filter((x) => x); return ( Home {pathnames.map((value, index) => { const last = index === pathnames.length - 1; const to = `/${pathnames.slice(0, index + 1).join('/')}`; return last ? ( {breadcrumbNameMap[to]} ) : ( {breadcrumbNameMap[to]} ); })} ); } export default function RouterBreadcrumbs() { const [open, setOpen] = React.useState(true); const handleClick = () => { setOpen((prevOpen) => !prevOpen); }; return ( } /> ); } ``` ## Accessibility (WAI-ARIA: https://www.w3.org/WAI/ARIA/apg/patterns/breadcrumb/) Be sure to add a `aria-label` description on the `Breadcrumbs` component. The accessibility of this component relies on: - The set of links is structured using an ordered list (`
      ` element). - To prevent screen reader announcement of the visual separators between links, they are hidden with `aria-hidden`. - A nav element labeled with `aria-label` identifies the structure as a breadcrumb trail and makes it a navigation landmark so that it is easy to locate. # Breadcrumbs API ## Demos For examples and details on the usage of this React component, visit the component demo pages: - [Breadcrumbs](https://mui.com/material-ui/react-breadcrumbs/) ## Import ```jsx import Breadcrumbs from '@mui/material/Breadcrumbs'; // or import { Breadcrumbs } from '@mui/material'; ``` ## Props | Name | Type | Default | Required | Description | |------|------|---------|----------|-------------| | children | `node` | - | No | | | classes | `object` | - | No | Override or extend the styles applied to the component. | | component | `elementType` | - | No | | | expandText | `string` | `'Show path'` | No | | | itemsAfterCollapse | `integer` | `1` | No | | | itemsBeforeCollapse | `integer` | `1` | No | | | maxItems | `integer` | `8` | No | | | separator | `node` | `'/'` | No | | | slotProps | `{ collapsedIcon?: func \| object }` | `{}` | No | | | slots | `{ CollapsedIcon?: elementType }` | `{}` | No | | | sx | `Array \| func \| object` | - | No | The system prop that allows defining system overrides as well as additional CSS styles. | > **Note**: The `ref` is forwarded to the root element (HTMLElement). > Any other props supplied will be provided to the root element ([Typography](https://mui.com/material-ui/api/typography/)). ## Inheritance While not explicitly documented above, the props of the [Typography](https://mui.com/material-ui/api/typography/) component are also available on Breadcrumbs. ## Theme default props You can use `MuiBreadcrumbs` to change the default props of this component with the theme. ## CSS ### Rule name | Global class | Rule name | Description | |--------------|-----------|-------------| | - | li | Styles applied to the li element. | | - | ol | Styles applied to the ol element. | | - | root | Styles applied to the root element. | | - | separator | Styles applied to the separator element. | ## Source code If you did not find the information on this page, consider having a look at the implementation of the component for more detail. - [/packages/mui-material/src/Breadcrumbs/Breadcrumbs.js](https://github.com/mui/material-ui/tree/HEAD/packages/mui-material/src/Breadcrumbs/Breadcrumbs.js) # Link API ## Demos For examples and details on the usage of this React component, visit the component demo pages: - [Breadcrumbs](https://mui.com/material-ui/react-breadcrumbs/) - [Links](https://mui.com/material-ui/react-link/) ## Import ```jsx import Link from '@mui/material/Link'; // or import { Link } from '@mui/material'; ``` ## Props | Name | Type | Default | Required | Description | |------|------|---------|----------|-------------| | children | `node` | - | No | | | classes | `object` | - | No | Override or extend the styles applied to the component. | | color | `'primary' \| 'secondary' \| 'success' \| 'error' \| 'info' \| 'warning' \| 'textPrimary' \| 'textSecondary' \| 'textDisabled' \| string` | `'primary'` | No | | | component | `element type` | - | No | | | sx | `Array \| func \| object` | - | No | The system prop that allows defining system overrides as well as additional CSS styles. | | TypographyClasses | `object` | - | No | | | underline | `'always' \| 'hover' \| 'none'` | `'always'` | No | | | variant | `'body1' \| 'body2' \| 'button' \| 'caption' \| 'h1' \| 'h2' \| 'h3' \| 'h4' \| 'h5' \| 'h6' \| 'inherit' \| 'overline' \| 'subtitle1' \| 'subtitle2' \| string` | `'inherit'` | No | | > **Note**: The `ref` is forwarded to the root element (HTMLAnchorElement). > Any other props supplied will be provided to the root element ([Typography](https://mui.com/material-ui/api/typography/)). ## Inheritance While not explicitly documented above, the props of the [Typography](https://mui.com/material-ui/api/typography/) component are also available on Link. ## Theme default props You can use `MuiLink` to change the default props of this component with the theme. ## CSS ### Rule name | Global class | Rule name | Description | |--------------|-----------|-------------| | - | button | Styles applied to the root element if `component="button"`. | | `.Mui-focusVisible` | - | State class applied to the root element if the link is keyboard focused. | | - | root | Styles applied to the root element. | | - | underlineAlways | Styles applied to the root element if `underline="always"`. | | - | underlineHover | Styles applied to the root element if `underline="hover"`. | | - | underlineNone | Styles applied to the root element if `underline="none"`. | ## Source code If you did not find the information on this page, consider having a look at the implementation of the component for more detail. - [/packages/mui-material/src/Link/Link.js](https://github.com/mui/material-ui/tree/HEAD/packages/mui-material/src/Link/Link.js) # Typography API ## Demos For examples and details on the usage of this React component, visit the component demo pages: - [Breadcrumbs](https://mui.com/material-ui/react-breadcrumbs/) - [Menubar](https://mui.com/material-ui/react-menubar/) - [Typography](https://mui.com/material-ui/react-typography/) ## Import ```jsx import Typography from '@mui/material/Typography'; // or import { Typography } from '@mui/material'; ``` ## Props | Name | Type | Default | Required | Description | |------|------|---------|----------|-------------| | align | `'center' \| 'inherit' \| 'justify' \| 'left' \| 'right'` | `'inherit'` | No | | | children | `node` | - | No | | | classes | `object` | - | No | Override or extend the styles applied to the component. | | color | `'primary' \| 'secondary' \| 'success' \| 'error' \| 'info' \| 'warning' \| 'textPrimary' \| 'textSecondary' \| 'textDisabled' \| string` | - | No | | | component | `elementType` | - | No | | | gutterBottom | `bool` | `false` | No | | | noWrap | `bool` | `false` | No | | | sx | `Array \| func \| object` | - | No | The system prop that allows defining system overrides as well as additional CSS styles. | | variant | `'body1' \| 'body2' \| 'button' \| 'caption' \| 'h1' \| 'h2' \| 'h3' \| 'h4' \| 'h5' \| 'h6' \| 'inherit' \| 'overline' \| 'subtitle1' \| 'subtitle2' \| string` | `'body1'` | No | | | variantMapping | `object` | `{ h1: 'h1', h2: 'h2', h3: 'h3', h4: 'h4', h5: 'h5', h6: 'h6', subtitle1: 'h6', subtitle2: 'h6', body1: 'p', body2: 'p', inherit: 'p', }` | No | | > **Note**: The `ref` is forwarded to the root element (HTMLParagraphElement). > Any other props supplied will be provided to the root element (native element). ## Theme default props You can use `MuiTypography` to change the default props of this component with the theme. ## CSS ### Rule name | Global class | Rule name | Description | |--------------|-----------|-------------| | - | alignCenter | Styles applied to the root element if `align="center"`. | | - | alignJustify | Styles applied to the root element if `align="justify"`. | | - | alignLeft | Styles applied to the root element if `align="left"`. | | - | alignRight | Styles applied to the root element if `align="right"`. | | - | body1 | Styles applied to the root element if `variant="body1"`. | | - | body2 | Styles applied to the root element if `variant="body2"`. | | - | button | Styles applied to the root element if `variant="button"`. | | - | caption | Styles applied to the root element if `variant="caption"`. | | - | gutterBottom | Styles applied to the root element if `gutterBottom={true}`. | | - | h1 | Styles applied to the root element if `variant="h1"`. | | - | h2 | Styles applied to the root element if `variant="h2"`. | | - | h3 | Styles applied to the root element if `variant="h3"`. | | - | h4 | Styles applied to the root element if `variant="h4"`. | | - | h5 | Styles applied to the root element if `variant="h5"`. | | - | h6 | Styles applied to the root element if `variant="h6"`. | | - | inherit | Styles applied to the root element if `variant="inherit"`. | | - | noWrap | Styles applied to the root element if `nowrap={true}`. | | - | overline | Styles applied to the root element if `variant="overline"`. | | - | root | Styles applied to the root element. | | - | subtitle1 | Styles applied to the root element if `variant="subtitle1"`. | | - | subtitle2 | Styles applied to the root element if `variant="subtitle2"`. | ## Source code If you did not find the information on this page, consider having a look at the implementation of the component for more detail. - [/packages/mui-material/src/Typography/Typography.js](https://github.com/mui/material-ui/tree/HEAD/packages/mui-material/src/Typography/Typography.js)