Menu

An accessible dropdown menu for the common dropdown menu button design pattern. Menu uses roving tabIndex for focus management.

    SourceTheme source@chakra-ui/menu

Props#

arrowPadding

Description

The padding required to prevent the arrow from reaching the very edge of the popper.

Type
number
Default
8

autoSelect

Description

If true, the first enabled menu item will receive focus and be selected when the menu opens.

Type
boolean
Default
true

boundary

Description

The boundary area for the popper. Used within the preventOverflow modifier

Type
"clippingParents" | "scrollParent" | HTMLElement
Default
clippingParents

closeOnBlur

Description

If true, the menu will close when you click outside the menu list

Type
boolean
Default
true

closeOnSelect

Description

If true, the menu will close when a menu item is clicked

Type
boolean
Default
true

computePositionOnMount

Type
boolean

defaultIsOpen

Type
boolean

direction

Description

If rtl, poper placement positions will be flipped i.e. 'top-right' will become 'top-left' and vice-verse

Type
"ltr" | "rtl"

eventListeners

Description

If provided, determines whether the popper will reposition itself on scroll and resize of the window.

Type
type ONLY_FOR_FORMAT = | boolean | { scroll?: boolean | undefined resize?: boolean | undefined }
Default
true

flip

Description

If true, the popper will change its placement and flip when it's about to overflow its boundary area.

Type
boolean
Default
true

gutter

Description

The distance or margin between the reference and popper. It is used internally to create an offset modifier. NB: If you define offset prop, it'll override the gutter.

Type
number
Default
8

id

Type
string

initialFocusRef

Description

The ref of the element that should receive focus when the popover opens.

Type
RefObject<{ focus(): void }>

isLazy

Description

Performance 🚀: If true, the MenuItem rendering will be deferred until the menu is open.

Type
boolean
Default
false

isOpen

Type
boolean

lazyBehavior

Description

Performance 🚀: The lazy behavior of menu's content when not visible. Only works when `isLazy={true}` - "unmount": The menu's content is always unmounted when not open. - "keepMounted": The menu's content initially unmounted, but stays mounted when menu is open.

Type
LazyMode
Default
unmount

matchWidth

Description

If true, the popper will match the width of the reference at all times. It's useful for autocomplete, `date-picker` and select patterns.

Type
boolean
Default
false

modifiers

Description

Array of popper.js modifiers. Check the docs to see the list of possible modifiers you can pass.

Type
Partial<Modifier<string, any>>[]

offset

Description

The main and cross-axis offset to displace popper element from its reference element.

Type
[number, number]

onClose

Type
() => void

onOpen

Type
() => void

placement

Description

The placement of the popper relative to its reference.

Type
PlacementWithLogical
Default
bottom

preventOverflow

Description

If true, will prevent the popper from being cut off and ensure it's visible within the boundary area.

Type
boolean
Default
true

strategy

Description

The CSS positioning strategy to use.

Type
"absolute" | "fixed"
Default
absolute

MenuButton composes Box so you can pass all Box props to change its style.

MenuList composes Box so you can pass all Box props to change its style.

motionProps

Description

The framer-motion props to animate the menu list

Type
HTMLMotionProps<"div">

rootProps

Description

Props for the root element that positions the menu.

Type
HTMLChakraProps<"div">

closeOnSelect

Description

Overrides the parent menu's closeOnSelect prop.

Type
boolean

command

Description

Right-aligned label text content, useful for displaying hotkeys.

Type
string

commandSpacing

Description

The spacing between the command and menu item's label.

Type
ResponsiveValue<string | number | (string & {})>

icon

Description

The icon to render before the menu item's label.

Type
ReactElement<any, string | JSXElementConstructor<any>>

iconSpacing

Description

The spacing between the icon and menu item's label.

Type
ResponsiveValue<string | number | (string & {})>

isDisabled

Description

If true, the menuitem will be disabled

Type
boolean

isFocusable

Description

If true and the menuitem is disabled, it'll remain keyboard-focusable

Type
boolean

MenuGroup composes Box so you can pass all Box props to change its style.

defaultValue

Type
string | string[]

onChange

Type
(value: string | string[]) => void

type

Type
"radio" | "checkbox"

value

Type
string | string[]

MenuItemOption composes Box so you can pass all box props in addition to these:

closeOnSelect

Description

Overrides the parent menu's closeOnSelect prop.

Type
boolean

command

Description

Right-aligned label text content, useful for displaying hotkeys.

Type
string

commandSpacing

Description

The spacing between the command and menu item's label.

Type
ResponsiveValue<string | number | (string & {})>

icon

Type
ReactElement<any, string | JSXElementConstructor<any>>

iconSpacing

Description

The spacing between the icon and menu item's label.

Type
ResponsiveValue<string | number | (string & {})>

isChecked

Type
boolean

isDisabled

Description

If true, the menuitem will be disabled

Type
boolean

isFocusable

Description

If true and the menuitem is disabled, it'll remain keyboard-focusable

Type
boolean

type

Type
"radio" | "checkbox"

value

Type
string
Edit this page on GitHub

Proudly made inNigeria by Segun Adebayo

Deployed by â–² Vercel