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
HTMLElement | "clippingParents" | "scrollParent"
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

colorScheme

Description

Color Schemes for Menu are not implemented in the default theme. You can extend the theme to implement them.

Type
string

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
boolean | { scroll?: boolean; 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

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

modifiers

Description

Array of popper.js modifiers. Check the docs to see the list of possible modifiers you can pass. @see Docs https://popper.js.org/docs/v2/modifiers/

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

size

Description

Sizes for Menu are not implemented in the default theme. You can extend the theme to implement them.

Type
string

strategy

Description

The CSS positioning strategy to use.

Type
"fixed" | "absolute"
Default
"absolute"

variant

Description

Variants for Menu are not implemented in the default theme. You can extend the theme to implement them.

Type
string

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
SystemProps["ml"]

icon

Description

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

Type
React.ReactElement

iconSpacing

Description

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

Type
SystemProps["mr"]

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
"checkbox" | "radio"

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
SystemProps["ml"]

icon

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

iconSpacing

Description

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

Type
SystemProps["mr"]

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
"checkbox" | "radio"

value

Type
string
Edit this page on GitHub

Proudly made inNigeria by Segun Adebayo

Deployed by â–² Vercel