Examples
SubmenuRendering nested Menu components to create a dropdown menu with submenus that open when hovering over the parent menu item.
MenuItemCheckboxRendering a dropdown Menu using the MenuItemCheckbox component with the values and setValues props from MenuProvider to control the checked items.
Menu with Framer MotionAbstracting Menu into a reusable dropdown menu component that uses Framer Motion to create smooth initial and exit animations.
Menu with TooltipRendering Menu with a Tooltip that appears when hovering over the MenuButton component by combining it with the TooltipAnchor component.
API
Styling
Styling the active item
When browsing the list with a keyboard (or hovering over items with the mouse when the focusOnHover
prop is true
), the active item element will have a data-active-item
attribute. You can use this attribute to style the active item:
.menu-item[data-active-item] {
background-color: hsl(204 100% 40%);
color: white;
}
Learn more on the Styling guide.