diff --git a/docs/data/material/components/breadcrumbs/CondensedWithMenu.js b/docs/data/material/components/breadcrumbs/CondensedWithMenu.js new file mode 100644 index 00000000000000..8a0d1205a2a1d3 --- /dev/null +++ b/docs/data/material/components/breadcrumbs/CondensedWithMenu.js @@ -0,0 +1,53 @@ +import * as React from 'react'; +import Breadcrumbs from '@mui/material/Breadcrumbs'; +import Button from '@mui/material/Button'; +import Link from '@mui/material/Link'; +import Menu from '@mui/material/Menu'; +import MenuItem from '@mui/material/MenuItem'; + +export default function CondensedWithMenu() { + const [anchorEl, setAnchorEl] = React.useState(null); + const open = Boolean(anchorEl); + const handleClick = (event) => { + if (event) { + setAnchorEl(event.currentTarget); + } + }; + const handleClose = () => { + setAnchorEl(null); + }; + + return ( + + + Breadcrumb 2 + Breadcrumb 3 + Breadcrumb 4 + + + + Breadcrumb 1 + + + + Breadcrumb 5 + + + Breadcrumb 6 + + + + ); +} diff --git a/docs/data/material/components/breadcrumbs/CondensedWithMenu.tsx b/docs/data/material/components/breadcrumbs/CondensedWithMenu.tsx new file mode 100644 index 00000000000000..c7cd79f933f5d4 --- /dev/null +++ b/docs/data/material/components/breadcrumbs/CondensedWithMenu.tsx @@ -0,0 +1,53 @@ +import * as React from 'react'; +import Breadcrumbs from '@mui/material/Breadcrumbs'; +import Button from '@mui/material/Button'; +import Link from '@mui/material/Link'; +import Menu from '@mui/material/Menu'; +import MenuItem from '@mui/material/MenuItem'; + +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 + + + + ); +} diff --git a/docs/data/material/components/breadcrumbs/breadcrumbs.md b/docs/data/material/components/breadcrumbs/breadcrumbs.md index 7468c550e3eba1..f61636093f2d5e 100644 --- a/docs/data/material/components/breadcrumbs/breadcrumbs.md +++ b/docs/data/material/components/breadcrumbs/breadcrumbs.md @@ -36,6 +36,12 @@ In the following examples, we are using two string separators and an SVG icon. {{"demo": "CollapsedBreadcrumbs.js"}} +## Condensed with menu + +As an alternative, consider adding a Menu component to display the condensed links in a dropdown list: + +{{"demo": "CondensedWithMenu.js"}} + ## Customization Here is an example of customizing the component. diff --git a/packages/mui-material/src/Breadcrumbs/Breadcrumbs.js b/packages/mui-material/src/Breadcrumbs/Breadcrumbs.js index a398e73d9fd778..a648dfbc14edb4 100644 --- a/packages/mui-material/src/Breadcrumbs/Breadcrumbs.js +++ b/packages/mui-material/src/Breadcrumbs/Breadcrumbs.js @@ -152,7 +152,7 @@ const Breadcrumbs = React.forwardRef(function Breadcrumbs(inProps, ref) { key="ellipsis" slots={{ CollapsedIcon: slots.CollapsedIcon }} slotProps={{ collapsedIcon: collapsedIconSlotProps }} - onClick={handleClickExpand} + onClick={collapsedIconSlotProps.onClick || handleClickExpand} />, ...allItems.slice(allItems.length - itemsAfterCollapse, allItems.length), ];