Nav overflow
Automatically collapse navigation items into a "More" menu when space is limited using the Priority+ pattern.
How it works
The nav overflow component (also known as the "Priority+" pattern) automatically detects when navigation items don’t fit within their container and moves them into a menu. This provides a responsive navigation experience without requiring different markup for different screen sizes.
Here’s what you need to know before getting started:
- Place
NavLinkandMenuchildren insideNavOverflow, and give the wrapper a uniqueid. - Responds to container size, not viewport size. The component watches the wrapper with a ResizeObserver, so it works in embedded contexts, documentation examples, and responsive containers.
- The wrapper is what makes this reliable. Collapsing items changes the width of the nav, so the component measures the wrapper instead. Measuring the nav would feed the result back in as the input.
- Overflow items are represented in a "More" menu while the originals are hidden. A nav item that hosts a menu becomes a submenu of the overflow menu.
- Works with all nav styles: default, pills, tabs, and underline.
- Active and disabled states are preserved in the overflow menu.
The animation effect depends on the
prefers-reduced-motionmedia query. See the reduced motion accessibility guidance.
Examples
Wrap the links in <NavOverflow id="…">. When items don’t fit, they’ll automatically move to a "More" menu. Resize the browser to see how nav items automatically move to the "More" menu as space becomes limited.
<NavOverflow
id="overflow-example-7"
variant="pills"
>
<NavLink
active
aria-current="page"
href="#"
>
Home
</NavLink>
<NavLink href="#">
Dashboard
</NavLink>
<NavLink href="#">
Products
</NavLink>
<NavLink href="#">
Services
</NavLink>
<NavLink href="#">
Analytics
</NavLink>
<NavLink href="#">
Reports
</NavLink>
<NavLink href="#">
Settings
</NavLink>
<NavLink href="#">
Help
</NavLink>
</NavOverflow>With tabs
The overflow pattern works seamlessly with tabbed navigation:
<NavOverflow
id="overflow-example-6"
variant="tabs"
>
<NavLink
active
aria-current="page"
href="#"
>
Overview
</NavLink>
<NavLink href="#">
Details
</NavLink>
<NavLink href="#">
History
</NavLink>
<NavLink href="#">
Activity
</NavLink>
<NavLink href="#">
Comments
</NavLink>
<NavLink href="#">
Attachments
</NavLink>
<NavLink href="#">
Related
</NavLink>
</NavOverflow>With underline
<NavOverflow
id="overflow-example-5"
variant="underline"
>
<NavLink
active
aria-current="page"
href="#"
>
Home
</NavLink>
<NavLink href="#">
Features
</NavLink>
<NavLink href="#">
Pricing
</NavLink>
<NavLink href="#">
FAQs
</NavLink>
<NavLink href="#">
About
</NavLink>
<NavLink href="#">
Contact
</NavLink>
</NavOverflow>Keep items visible
Pass className="nav-overflow-keep" to any item that should never be moved to the overflow menu. These items remain visible regardless of available space—useful for high-priority items like "Home" or action buttons.
<NavOverflow
id="overflow-example-4"
variant="pills"
>
<NavLink
active
aria-current="page"
className="nav-overflow-keep"
href="#"
>
Home
</NavLink>
<NavLink href="#">
Products
</NavLink>
<NavLink href="#">
Services
</NavLink>
<NavLink href="#">
About
</NavLink>
<NavLink href="#">
Blog
</NavLink>
<NavLink href="#">
Careers
</NavLink>
<NavLink
className="nav-overflow-keep"
href="#"
>
Contact
</NavLink>
</NavOverflow>With disabled items
Disabled states are preserved when items move to the overflow menu:
<NavOverflow
id="overflow-example-3"
variant="pills"
>
<NavLink
active
aria-current="page"
href="#"
>
Active
</NavLink>
<NavLink href="#">
Link
</NavLink>
<NavLink href="#">
Another link
</NavLink>
<NavLink
aria-disabled="true"
disabled
>
Disabled
</NavLink>
<NavLink href="#">
More content
</NavLink>
<NavLink href="#">
Even more
</NavLink>
</NavOverflow>In a navbar
The nav overflow pattern can also be used within a navbar for horizontal navigation that adapts to available space:
<Navbar
className="bg-1"
expand
>
<Container fluid>
<NavbarBrand href="#">
Brand
</NavbarBrand>
<NavOverflow id="overflow-example-2">
<NavLink
active
aria-current="page"
href="#"
>
Home
</NavLink>
<NavLink href="#">
Features
</NavLink>
<NavLink href="#">
Pricing
</NavLink>
<NavLink href="#">
About
</NavLink>
<NavLink href="#">
Contact
</NavLink>
</NavOverflow>
</Container>
</Navbar>With menus
A nav item that already hosts a menu becomes a submenu of the overflow menu. Its nested submenus stay intact.
<NavOverflow
id="overflow-example-1"
variant="pills"
>
<NavLink
active
aria-current="page"
href="#"
>
Home
</NavLink>
<NavLink href="#">
Dashboard
</NavLink>
<Menu
label="Products"
nav
>
<MenuItem href="#">
Laptops
</MenuItem>
<MenuSubmenu label="Phones">
<MenuItem href="#">
iPhone
</MenuItem>
<MenuItem href="#">
Android
</MenuItem>
</MenuSubmenu>
<MenuItem href="#">
Tablets
</MenuItem>
</Menu>
<NavLink href="#">
Services
</NavLink>
<Menu
label="Company"
nav
>
<MenuItem href="#">
About
</MenuItem>
<MenuItem href="#">
Careers
</MenuItem>
<MenuItem href="#">
Press
</MenuItem>
</Menu>
<NavLink href="#">
Analytics
</NavLink>
<NavLink href="#">
Reports
</NavLink>
<NavLink href="#">
Help
</NavLink>
</NavOverflow>Customizing the toggle
Custom text
Use the moreText option to customize the text shown in the overflow toggle button:
<NavOverflow id="custom-text" moreText="See all">
<NavLink href="#first">First</NavLink>
<NavLink href="#second">Second</NavLink>
</NavOverflow>
Custom icon
Provide a custom icon via the moreIcon prop, using the Icon component:
<NavOverflow id="custom-icon" moreIcon={<Icon name="three-dots" />} moreText={false}>
<NavLink href="#first">First</NavLink>
<NavLink href="#second">Second</NavLink>
</NavOverflow>
Set moreText to false for an icon-only toggle. The component labels the button aria-label="More" so it still has an accessible name. An empty string does the same. React nodes are passed directly through moreIcon; HTML strings and data-bs-overflow-icon extraction are not used.
Icon placement
Use the iconPlacement option to position the icon before ('start', the default) or after ('end') the text:
<NavOverflow id="icon-placement" moreText="Menu" iconPlacement="end">
<NavLink href="#first">First</NavLink>
<NavLink href="#second">Second</NavLink>
</NavOverflow>
Minimum visible items
Use the threshold option to ensure a minimum number of items remain visible before the overflow kicks in:
<NavOverflow id="minimum-visible" threshold={3}>
<NavLink href="#first">First</NavLink>
<NavLink href="#second">Second</NavLink>
<NavLink href="#third">Third</NavLink>
<NavLink href="#fourth">Fourth</NavLink>
</NavOverflow>
Collapse all
Use the collapseBelow option to force all items into the overflow dropdown when the wrapper’s width is below a threshold. Pass a breakpoint name to resolve the value from --bs-breakpoint-{name}, or a number for a direct pixel value.
<NavOverflow id="collapse-at-breakpoint" variant="pills" collapseBelow="md">
<NavLink href="#">{'Link 1'}</NavLink>
<NavLink href="#">{'Link 2'}</NavLink>
<NavLink href="#">{'Link 3'}</NavLink>
</NavOverflow>
Or use a raw pixel value:
<NavOverflow id="collapse-at-width" collapseBelow={768}>
<NavLink href="#first">First</NavLink>
<NavLink href="#second">Second</NavLink>
</NavOverflow>
Above the threshold, normal progressive collapse resumes. Items with nav-overflow-keep in their className are never collapsed.
Usage
Options
Pass options as React props. The component initializes on mount, updates on resize, and disposes its observers on unmount.
| Name | Type | Default | Description |
|---|---|---|---|
collapseBelow | number or string | 0 | Wrapper width below which all items collapse. Pass a breakpoint name or a pixel value; 0 disables this behavior. |
iconPlacement | 'start' or 'end' | 'start' | Position of the icon relative to the toggle text. |
menuPlacement | string | 'bottom-end' | Placement of the overflow menu. |
menuStrategy | 'absolute' or 'fixed' | 'absolute' | Use 'fixed' when an overflow ancestor would clip the menu. |
moreText | string or false | 'More' | Toggle label; false or an empty string produces an icon-only toggle. |
moreIcon | ReactNode | Chevron icon | Custom toggle icon. |
threshold | number | 0 | Minimum number of items to keep visible before showing overflow. |
minimumVisibleItems | number | threshold | Explicit alias that takes precedence over threshold. |
Methods
The instance method updateOverflow() manually recalculates overflow. Resizing and prop changes already trigger it automatically.
Events
Use onOverflowChange(overflowCount, visibleCount) to observe overflow calculations.