Menubar

Designer doc
Menubar is slightly different from SideMenu even though they have similar role and other aria properties. While SideMenu is normally used solely for navigation, Menubar’s items can be used for checkboxes or radios.
If you’re using macOS, you can move your mouse to menubar on the top and explore all the items there - you might find some items with checkmark on the left of its label. That item can either be checkbox or radio. You can find more thorough explanation and example in WAI-ARIA Editor Menubar Example.

Example

Basic Usage
View code
View code
Variants
View code
Controlled MenubarGroupLabel
label prop can be used to display its selected MenubarGroupItem with some customization
View code
Routing Library Integrations
React Router DOM
react-router-dom will highlight matched routes with ‘aria-current=page’. This is an alternative to the selected prop which also help with accessibility.
The default activeAttribute is ‘aria-current=page’, which is used to find the active menubar item.
Below is an example with React Router’s MemoryRouter to sort of mock the URL instead of using the real one. So, don’t include MemoryRouter in your application, just use your normal BrowserRouter.
View code
you can also use customized active class name, just remember to pass it in the activeAttribute prop.
View code
@reach/router
reach/router does not highlight partially matched route with aria-current=page by default, you can add that by yourself for easier integration.
Similarly, you can ignore <LocationProvider/> part since it’s just for demonstration purposes.
View code
Alternatively, you may declare your own attribute to highlight matched route.
View code

Accessibility

This component’s aria attributes and keyboard interactions follow WAI-ARIA’s Menu bar design pattern.
Some keyboard interactions are:
  • ArrowLeft and ArrowRight to navigate through items in Menubar.
  • ArrowUp and ArrowDown to expand and focus sub item for MenubarGroup directly under Menubar.
  • Escape to collapse current MenubarGroup.
  • ArrowRight and ArrowLeft to expand and collapse nested MenubarGroup.
  • ArrowRight and ArrowLeft at the edge will focus the next or previous item in Menubar.

References

API

Prop nameTypeDefaultDescription
activeAttributestring[aria-current='page']
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
navPropsNavProps
underlineReactElement<any, string | JSXElementConstructor<any>>
variantNavbarVariants
Prop nameTypeDefaultDescription
activeboolean
arrowArrowProps
asanyanimated.ul
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
buttonProps(MenubarItemProps | MenubarGroupItemProps) & { ref?: Ref<HTMLAnchorElement>; }
containerHTMLElementconfigs.getPortalContainer('MenubarGroup', 'container')
disableScrollLockboolean
immediateboolean
indexnumber
initialActiveboolean
labelReactNode
labelArrowReactNode
offset[number, number]
onActiveChange(active: boolean) => void
placement"left" | "right" | "bottom" | "top" | "top-start" | "top-end" | "left-start" | "left-end" | "right-start" | "right-end" | "bottom-start" | "bottom-end"
popperOptionsPopperPopperOptions
Options for Popper.js instance
popperUpdateKeystring
springConfigPartial<AnimationConfig>{ tension: 720, mass: 0.5 }
Prop nameTypeDefaultDescription
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
disabledboolean
indexnumber
keyboardClickKeysstring[]['Enter', ' ']
listItemPropsMenubarGroupItemListItemProps
selectedboolean
Prop nameTypeDefaultDescription
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
disabledboolean
indexnumber
keyboardClickKeysstring[]['Enter', ' ']
listItemPropsMenubarItemListItemProps
selectedboolean
Prop nameTypeDefaultDescription
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
basisnumber3
Height.
    Example
    Example
    Basic Usage
    Basic Usage
    Menu Group
    Menu Group
    Variants
    Variants
    Controlled MenubarGroupLabel
    Controlled MenubarGroupLabel
    Routing Library Integrations
    Routing Library Integrations
    Accessibility
    Accessibility
    References
    References
    API
    API
    Menubar
    Menubar
    MenubarGroup
    MenubarGroup
    MenubarGroupItem
    MenubarGroupItem
    MenubarItem
    MenubarItem
    MenubarUnderline
    MenubarUnderline
Coral is a thoroughly developed design system widely adopted by developers and designers for creating beautiful and user-friendly Sea internal products.

Copyright © 2018-2025 Sea Labs