Breadcrumbs 面包屑导航
Breadcrumbs consist of a list of links that help a user visualize a page's location within the hierarchical structure of a website, and allow navigation up to any of its "ancestors".
<Breadcrumbs aria-label="breadcrumb">
<Link underline="hover" color="inherit" href="/">
MUI
</Link>
<Link
underline="hover"
color="inherit"
href="/material-ui/getting-started/installation/"
>
Core
</Link>
<Typography color="text.primary">Breadcrumbs</Typography>
</Breadcrumbs>
<Breadcrumbs separator="›" aria-label="breadcrumb">
{breadcrumbs}
</Breadcrumbs>
<Breadcrumbs separator="-" aria-label="breadcrumb">
{breadcrumbs}
</Breadcrumbs>
<Breadcrumbs
separator={<NavigateNextIcon fontSize="small" />}
aria-label="breadcrumb"
>
{breadcrumbs}
</Breadcrumbs>
<Breadcrumbs maxItems={2} aria-label="breadcrumb">
<Link underline="hover" color="inherit" href="#">
Home
</Link>
<Link underline="hover" color="inherit" href="#">
Catalog
</Link>
<Link underline="hover" color="inherit" href="#">
Accessories
</Link>
<Link underline="hover" color="inherit" href="#">
New Collection
</Link>
<Typography color="text.primary">Belts</Typography>
</Breadcrumbs>
自定义的面包屑导航
以下是自定义组件的一个示例。 You can learn more about this in the overrides documentation page.
<Breadcrumbs aria-label="breadcrumb">
<StyledBreadcrumb
component="a"
href="#"
label="Home"
icon={<HomeIcon fontSize="small" />}
/>
<StyledBreadcrumb component="a" href="#" label="Catalog" />
<StyledBreadcrumb
label="Accessories"
deleteIcon={<ExpandMoreIcon />}
onDelete={handleClick}
/>
</Breadcrumbs>
无障碍设计
(WAI-ARIA: https://www.w3.org/WAI/ARIA/apg/patterns/breadcrumb/)
请务必在面包屑导航
组件上加上 aria-label
的描述。
这个组件的可访问性依赖于:
- 这组链接是由一个有序列表(
<ol>
元素)组建的。 - 用
aria-hidden
属性隐藏各个链接之间的分隔符,这样屏幕阅读器不会把它们朗读出来。 - 有一个标有
aria-label
的 nav(导航)元素标记了面包屑导航的结构,并使其成为导航的标记,这样更容易定位。