Loading...
Skip to main content

Menu

Toggle contextual menus and custom overlays for lists of buttons, links, forms, and other custom content.

Overview

Toggle menus with buttons whenever possible. Here’s an example using an Idea React button:

<Menu label="Menu button">
<MenuItem href="#menu-items">
Action
</MenuItem>
<MenuItem href="#menu-items">
Another action
</MenuItem>
<MenuItem href="#menu-items">
Something else here
</MenuItem>
</Menu>

Menus are toggleable, contextual overlays for displaying lists of links and more. They’re made interactive by the Menu wrapper. Positioning updates when the viewport or trigger geometry changes. They’re toggled by clicking, not by hovering; this is an intentional design decision.

Examples

Menu uses its button-based toggle. Unlike an upstream anchor example, the wrapper does not expose an alternate link toggle.

Use button groups to create split button menus where the menu is displayed when a secondary button is clicked.

<div className="d-flex flex-wrap gap-3">
<Menu label="Menu button">
<MenuItem href="#menu-items">
Action
</MenuItem>
<MenuItem href="#menu-items">
Another action
</MenuItem>
<MenuItem href="#menu-items">
Something else here
</MenuItem>
</Menu>
<ButtonGroup>
<Button
theme="secondary"
variant="solid"
>
Split
</Button>
<Menu
label={<><Icon name="chevron-expand" /><span className="visually-hidden">Toggle menu</span></>}
split
toggleProps={{
theme: 'secondary',
variant: 'solid'
}}
>
<MenuItem href="#menu-items">
Action
</MenuItem>
<MenuItem href="#menu-items">
Another action
</MenuItem>
<MenuItem href="#menu-items">
Something else here
</MenuItem>
<MenuDivider />
<MenuItem href="#examples">
Separated link
</MenuItem>
</Menu>
</ButtonGroup>
</div>

Dark menus

Opt into darker menus to match a dark navbar or custom style by passing theme="dark" to Menu, or adding data-bs-theme="dark" to a parent.

<Menu
label="Menu button"
theme="dark"
>
<MenuItem
active
href="#dark-menus"
>
Action
</MenuItem>
<MenuItem href="#dark-menus">
Another action
</MenuItem>
<MenuItem href="#dark-menus">
Something else here
</MenuItem>
<MenuDivider />
<MenuItem href="#dark-menus">
Separated link
</MenuItem>
</Menu>

And putting it to use in a navbar:

<Navbar theme="dark">
<Container fluid>
<NavbarBrand href="#dark-menus">
Navbar
</NavbarBrand>
<NavbarNav>
<li>
<Menu
label="Menu"
nav
theme="dark"
>
<MenuItem href="#menu-items">
Action
</MenuItem>
<MenuItem href="#menu-items">
Another action
</MenuItem>
<MenuItem href="#menu-items">
Something else here
</MenuItem>
</Menu>
</li>
</NavbarNav>
</Container>
</Navbar>

Translucent menus

Blur and saturate the background of menus to create a translucent effect with translucent.

<Menu
label="Translucent menu"
translucent
>
<MenuItem
active
href="#translucent-menus"
>
Active menu item
</MenuItem>
<MenuItem href="#menu-items">
Action
</MenuItem>
<MenuItem href="#menu-items">
Another action
</MenuItem>
<MenuItem href="#menu-items">
Something else here
</MenuItem>
<MenuDivider />
<MenuItem
href="#translucent-menus"
theme="danger"
>
Danger menu item
</MenuItem>
</Menu>

Placement

Use placement on Menu to control where the menu appears.

  • Physical placements: top-start, top-end, bottom-start, bottom-end, left-start, left-end, right-start, right-end — fixed directions regardless of text direction.
  • Edge alignment: the -start and -end suffixes select an edge of the trigger. The wrapper does not expose upstream logical start/end side placements or automatically mirror placement in RTL.

Use both a physical direction and an alignment, such as bottom-start or right-end.

<div className="d-flex flex-wrap gap-3">
<Menu
label="top-start"
placement="top-start"
>
<MenuItem href="#menu-items">
Action
</MenuItem>
<MenuItem href="#menu-items">
Another action
</MenuItem>
<MenuItem href="#menu-items">
Something else here
</MenuItem>
</Menu>
<Menu
label="top-end"
placement="top-end"
>
<MenuItem href="#menu-items">
Action
</MenuItem>
<MenuItem href="#menu-items">
Another action
</MenuItem>
<MenuItem href="#menu-items">
Something else here
</MenuItem>
</Menu>
<Menu
label="bottom-start"
placement="bottom-start"
>
<MenuItem href="#menu-items">
Action
</MenuItem>
<MenuItem href="#menu-items">
Another action
</MenuItem>
<MenuItem href="#menu-items">
Something else here
</MenuItem>
</Menu>
<Menu
label="bottom-end"
placement="bottom-end"
>
<MenuItem href="#menu-items">
Action
</MenuItem>
<MenuItem href="#menu-items">
Another action
</MenuItem>
<MenuItem href="#menu-items">
Something else here
</MenuItem>
</Menu>
<Menu
label="left-start"
placement="left-start"
>
<MenuItem href="#menu-items">
Action
</MenuItem>
<MenuItem href="#menu-items">
Another action
</MenuItem>
<MenuItem href="#menu-items">
Something else here
</MenuItem>
</Menu>
<Menu
label="left-end"
placement="left-end"
>
<MenuItem href="#menu-items">
Action
</MenuItem>
<MenuItem href="#menu-items">
Another action
</MenuItem>
<MenuItem href="#menu-items">
Something else here
</MenuItem>
</Menu>
<Menu
label="right-start"
placement="right-start"
>
<MenuItem href="#menu-items">
Action
</MenuItem>
<MenuItem href="#menu-items">
Another action
</MenuItem>
<MenuItem href="#menu-items">
Something else here
</MenuItem>
</Menu>
<Menu
label="right-end"
placement="right-end"
>
<MenuItem href="#menu-items">
Action
</MenuItem>
<MenuItem href="#menu-items">
Another action
</MenuItem>
<MenuItem href="#menu-items">
Something else here
</MenuItem>
</Menu>
</div>

Responsive

Change placement at different breakpoints using responsivePlacement={{ md: 'right', lg: 'bottom' }}, where each breakpoint is one of sm, md, lg, xl, or 2xl. Multiple breakpoints can be combined in the responsivePlacement object.

For example, placement="bottom-start" responsivePlacement={{ md: "bottom-end", lg: "right-start" }} will:

  • Show the menu at bottom-start on small screens (default)
  • Switch to bottom-end at the md breakpoint
  • Switch to right-start at the lg breakpoint
<div className="d-flex flex-wrap gap-3">
<Menu
label="Bottom start → md:bottom-end"
placement="bottom-start"
responsivePlacement={{
md: 'bottom-end'
}}
>
<MenuItem href="#menu-items">
Action
</MenuItem>
<MenuItem href="#menu-items">
Another action
</MenuItem>
<MenuItem href="#menu-items">
Something else here
</MenuItem>
</Menu>
<Menu
label="Bottom → lg:right"
placement="bottom-start"
responsivePlacement={{
lg: 'right-start'
}}
>
<MenuItem href="#menu-items">
Action
</MenuItem>
<MenuItem href="#menu-items">
Another action
</MenuItem>
<MenuItem href="#menu-items">
Something else here
</MenuItem>
</Menu>
</div>

Resize your browser window to see the placement change at different breakpoints.

Menu items

Use MenuItem for each entry. It renders a link when href is provided; set as="button" for an action.

We use utility classes to display menus in our docs examples, but they’re not required for your own use.

<MenuPanel
className="position-static max-w-100"
show
style={{
'--bs-menu-min-width': 'min(300px, 100%)',
width: 300
}}
>
<MenuItem>
Action
</MenuItem>
<MenuItem>
Another action
</MenuItem>
<MenuItem>
Something else here
</MenuItem>
</MenuPanel>

You can also create non-interactive menu items with MenuText. Feel free to style further with custom CSS or text utilities.

<MenuPanel
className="position-static max-w-100"
show
style={{
'--bs-menu-min-width': 'min(300px, 100%)',
width: 300
}}
>
<MenuText>
Menu item text
</MenuText>
<MenuItem href="#menu-items">
Action
</MenuItem>
<MenuItem href="#menu-items">
Another action
</MenuItem>
<MenuItem href="#menu-items">
Something else here
</MenuItem>
</MenuPanel>

Active

Pass active to MenuItem to style them as the active selection. To convey the active state to assistive technologies, use the aria-current attribute — using the page value for the current page, or true for the current item in a set.

<MenuPanel
className="position-static max-w-100"
show
style={{
'--bs-menu-min-width': 'min(300px, 100%)',
width: 300
}}
>
<MenuItem href="#active">
Regular link
</MenuItem>
<MenuItem
active
href="#active"
>
Active link
</MenuItem>
<MenuItem href="#active">
Another link
</MenuItem>
</MenuPanel>

Disabled

Pass disabled to MenuItem to style them as disabled.

<MenuPanel
className="position-static max-w-100"
show
style={{
'--bs-menu-min-width': 'min(300px, 100%)',
width: 300
}}
>
<MenuItem href="#disabled">
Regular link
</MenuItem>
<MenuItem
disabled
href="#disabled"
>
Disabled link
</MenuItem>
<MenuItem href="#disabled">
Another link
</MenuItem>
</MenuPanel>

Variants

You can use the theme prop to apply a theme color to a menu item.

<MenuPanel
className="position-static max-w-100"
show
style={{
'--bs-menu-min-width': 'min(300px, 100%)',
width: 300
}}
>
<MenuItem theme="primary">
Primary action
</MenuItem>
<MenuItem theme="success">
Success action
</MenuItem>
<MenuItem theme="danger">
Delete
</MenuItem>
</MenuPanel>

Icons

Use MenuItemIcon to add an icon slot to menu items. It renders the shared Icon component.

<MenuPanel
className="position-static max-w-100"
show
style={{
'--bs-menu-min-width': 'min(300px, 100%)',
width: 300
}}
>
<MenuItem>
<MenuItemIcon name="pencil" />
Edit
</MenuItem>
<MenuItem>
<MenuItemIcon name="copy" />
Duplicate
</MenuItem>
<MenuDivider />
<MenuItem theme="danger">
<MenuItemIcon name="trash" />
Delete
</MenuItem>
</MenuPanel>

Descriptions

Use MenuItemContent for a flex column layout and MenuItemDescription for secondary text below the main label.

<MenuPanel
className="position-static max-w-100"
show
style={{
'--bs-menu-min-width': 'min(300px, 100%)',
width: 300
}}
>
<MenuItem>
<MenuItemIcon name="person" />
<MenuItemContent>
Profile
<MenuItemDescription>
View your profile and settings
</MenuItemDescription>
</MenuItemContent>
</MenuItem>
<MenuItem>
<MenuItemIcon name="gear" />
<MenuItemContent>
Settings
<MenuItemDescription>
Manage your preferences
</MenuItemDescription>
</MenuItemContent>
</MenuItem>
</MenuPanel>

Selected

Pass selected to MenuItem to indicate the current selection.

<MenuPanel
className="position-static max-w-100"
show
style={{
'--bs-menu-min-width': 'min(300px, 100%)',
width: 300
}}
>
<MenuItem selected>
<MenuItemCheck />
Selected option
</MenuItem>
<MenuItem>
Another option
</MenuItem>
<MenuItem>
Something else
</MenuItem>
</MenuPanel>

Menu content

Headers

Add a header to label sections of actions in any menu.

<MenuPanel
className="position-static max-w-100"
show
style={{
'--bs-menu-min-width': 'min(300px, 100%)',
width: 300
}}
>
<MenuHeader>
Menu header
</MenuHeader>
<MenuItem href="#menu-items">
Action
</MenuItem>
<MenuItem href="#menu-items">
Another action
</MenuItem>
<MenuItem href="#menu-items">
Something else here
</MenuItem>
</MenuPanel>

Dividers

Separate groups of related menu items with a divider.

<MenuPanel
className="position-static max-w-100"
show
style={{
'--bs-menu-min-width': 'min(300px, 100%)',
width: 300
}}
>
<MenuItem href="#menu-items">
Action
</MenuItem>
<MenuItem href="#menu-items">
Another action
</MenuItem>
<MenuItem href="#menu-items">
Something else here
</MenuItem>
<MenuDivider />
<MenuItem href="#dividers">
Separated link
</MenuItem>
</MenuPanel>

Text

Place any freeform text within a menu with text and use margin and padding utilities. Note that you’ll likely need additional sizing styles to constrain the menu width.

<MenuPanel
className="position-static max-w-100"
show
style={{
'--bs-menu-min-width': 'min(300px, 100%)',
width: 300
}}
>
<div className="p-3 text-body-secondary">
<p>
Some example text that’s free-flowing within the menu.
</p>
<p className="mb-0">
And this is more example text.
</p>
</div>
</MenuPanel>

Forms

Put a form within a menu, or make it into a menu, and use margin and padding utilities to give it the negative space you require.

<MenuPanel
className="position-static max-w-100"
show
style={{
'--bs-menu-min-width': 'min(300px, 100%)',
width: 300
}}
>
<form className="p-3">
<FormField className="mb-3">
<FormLabel htmlFor="menuEmail">
Email address
</FormLabel>
<FormControl
id="menuEmail"
placeholder="email@example.com"
type="email"
/>
</FormField>
<FormField className="mb-3">
<FormLabel htmlFor="menuPassword">
Password
</FormLabel>
<FormControl
id="menuPassword"
placeholder="Password"
type="password"
/>
</FormField>
<FormLabel className="mb-3">
<Checkbox />
{' '}Remember me
</FormLabel>
<Button
theme="primary"
type="submit"
variant="solid"
>
Sign in
</Button>
</form>
<MenuDivider />
<MenuItem href="#forms">
New around here? Sign up
</MenuItem>
<MenuItem href="#forms">
Forgot password?
</MenuItem>
</MenuPanel>

Scrollable menus

Assign --bs-menu-max-height and --bs-menu-overflow-y custom properties to constrain the menu height and enable scrolling.

<Menu
label="Scrollable menu"
scrollable
>
<MenuItem href="#scrollable-menus">
Item 1
</MenuItem>
<MenuItem href="#scrollable-menus">
Item 2
</MenuItem>
<MenuItem href="#scrollable-menus">
Item 3
</MenuItem>
<MenuItem href="#scrollable-menus">
Item 4
</MenuItem>
<MenuItem href="#scrollable-menus">
Item 5
</MenuItem>
<MenuItem href="#scrollable-menus">
Item 6
</MenuItem>
<MenuItem href="#scrollable-menus">
Item 7
</MenuItem>
<MenuItem href="#scrollable-menus">
Item 8
</MenuItem>
<MenuItem href="#scrollable-menus">
Item 9
</MenuItem>
<MenuItem href="#scrollable-menus">
Item 10
</MenuItem>
<MenuItem href="#scrollable-menus">
Item 11
</MenuItem>
<MenuItem href="#scrollable-menus">
Item 12
</MenuItem>
<MenuItem href="#scrollable-menus">
Item 13
</MenuItem>
<MenuItem href="#scrollable-menus">
Item 14
</MenuItem>
<MenuItem href="#scrollable-menus">
Item 15
</MenuItem>
<MenuItem href="#scrollable-menus">
Item 16
</MenuItem>
<MenuItem href="#scrollable-menus">
Item 17
</MenuItem>
<MenuItem href="#scrollable-menus">
Item 18
</MenuItem>
<MenuItem href="#scrollable-menus">
Item 19
</MenuItem>
<MenuItem href="#scrollable-menus">
Item 20
</MenuItem>
</Menu>

You can also pass scrollable to make the menu scrollable. This assumes a generally safe maximum height of 80dvh and sets the overflow for you.

Submenus

Create nested menus with MenuSubmenu. Submenus support hover and click activation, keyboard navigation, and viewport-aware positioning. Submenus currently fly out to the side; the upstream small-screen stacked layout and back button are not exposed by the React wrapper.

Pass a label and nested menu items to MenuSubmenu; it renders and wires the trigger and panel.

<Menu label="Menu button">
<MenuItem href="#menu-items">
Action
</MenuItem>
<MenuItem href="#menu-items">
Another action
</MenuItem>
<MenuItem href="#menu-items">
Something else here
</MenuItem>
<MenuSubmenu label="More options">
<MenuItem>
Submenu action
</MenuItem>
<MenuItem>
Another action
</MenuItem>
<MenuItem>
Something else
</MenuItem>
</MenuSubmenu>
</Menu>

Nested

Submenus can be nested to multiple levels. Each level opens to the side and flips direction when there’s not enough viewport space.

<Menu label="Menu button">
<MenuItem>
Action
</MenuItem>
<MenuSubmenu label="More options">
<MenuItem>
Submenu action
</MenuItem>
<MenuSubmenu label="Even more">
<MenuItem>
Deep action
</MenuItem>
<MenuItem>
Another deep action
</MenuItem>
</MenuSubmenu>
</MenuSubmenu>
</Menu>

Menu options

Use offset to change the location of the menu. A number sets the distance from the trigger in pixels; [crossAxis, mainAxis] sets both axes. padding sets the viewport inset and flip={false} disables collision flipping. The trigger remains the positioning reference.

<div className="d-flex flex-wrap gap-3">
<Menu
label="Offset"
offset={[
10,
20
]}
>
<MenuItem href="#menu-items">
Action
</MenuItem>
<MenuItem href="#menu-items">
Another action
</MenuItem>
<MenuItem href="#menu-items">
Something else here
</MenuItem>
</Menu>
<Menu
flip={false}
label="No flip"
>
<MenuItem href="#menu-items">
Action
</MenuItem>
<MenuItem href="#menu-items">
Another action
</MenuItem>
<MenuItem href="#menu-items">
Something else here
</MenuItem>
</Menu>
</div>

Auto close behavior

By default, the menu is closed when clicking inside or outside the menu. You can use the autoClose option to change this behavior of the menu.

Regardless of the autoClose setting, pressing Esc while focus is within the menu (its toggle or items) closes the menu and returns focus to the toggle.

<div className="d-flex flex-wrap gap-3">
<Menu
autoClose
label="Default"
>
<MenuItem href="#menu-items">
Action
</MenuItem>
<MenuItem href="#menu-items">
Another action
</MenuItem>
<MenuItem href="#menu-items">
Something else here
</MenuItem>
</Menu>
<Menu
autoClose="inside"
label="Clickable inside"
>
<MenuItem href="#menu-items">
Action
</MenuItem>
<MenuItem href="#menu-items">
Another action
</MenuItem>
<MenuItem href="#menu-items">
Something else here
</MenuItem>
</Menu>
<Menu
autoClose="outside"
label="Clickable outside"
>
<MenuItem href="#menu-items">
Action
</MenuItem>
<MenuItem href="#menu-items">
Another action
</MenuItem>
<MenuItem href="#menu-items">
Something else here
</MenuItem>
</Menu>
<Menu
autoClose={false}
label="Manual close"
>
<MenuItem href="#menu-items">
Action
</MenuItem>
<MenuItem href="#menu-items">
Another action
</MenuItem>
<MenuItem href="#menu-items">
Something else here
</MenuItem>
</Menu>
</div>

Accessibility

The WAI ARIA standard defines an actual role="menu" widget, but this is specific to application-like menus which trigger actions or functions. ARIA menus can only contain menu items, checkbox menu items, radio button menu items, radio button groups, and sub-menus.

Idea React’s menus, on the other hand, are designed to be generic and applicable to a variety of situations and markup structures. For instance, it is possible to create menus that contain additional inputs and form controls, such as search fields or login forms. For this reason, Idea React does not expect (nor automatically add) any of the role and aria- attributes required for true ARIA menus. Authors will have to include these more specific attributes themselves.

Submenu triggers are an exception. MenuSubmenu adds aria-haspopup="true" to its trigger, and keeps aria-expanded on it in sync as the submenu opens and closes. The wrapper keeps this state in sync automatically.

Keyboard navigation

Menus include built-in keyboard support for navigating menu items. Submenu arrow keys remain physical directions in both LTR and RTL; the wrapper does not implement upstream RTL key reversal.

KeyAction
↓ / ↑Navigate to next/previous menu item
→Enter submenu
←Exit submenu and return to parent
Enter / SpaceActivate focused item or open submenu
EscClose the menu
Home / EndJump to first/last menu item
TabMove focus and close the menu

CSS

Variables

Local CSS custom properties expose the component’s colors, spacing, borders, and transitions. Override them through style or a CSS module. The defaults below come from the Bootstrap stylesheet used by Idea React; see the upstream variable reference.

VariableDefault
--bs-menu-max-height300px
--bs-menu-overflow-yauto

Usage

Menu manages its own open state, trigger wiring, positioning, and cleanup. Do not initialize Bootstrap’s plugin on the same elements.

Options

PropDefaultDescription
autoClosetrueClose on inside/outside clicks, only "inside", only "outside", or neither (false). Escape still dismisses the menu.
placement"bottom-end"Preferred side and edge alignment; align defaults to "end".
responsivePlacement—Override placement at named breakpoints.
offset0Distance from the toggle, or a [crossAxis, mainAxis] pair.
padding8Inset from the viewport edge when shifting to avoid overflow.
fliptrueFlip to another side when the preferred side lacks space.

Events

onOpenChange(open) receives the menu’s new visibility state.

Documentation navigation
On this page
On this page