Inline menu that is always visible
import {Menu} from "@peakui/react" ;
import {Label, Menu, Separator} from "@peakui/react" ;
// Menu.Item, Menu.Section and the indicators are the menu parts shared with Dropdown.
// Dividers use Separator; there is no Menu.Separator.
export default () => (
< Menu aria-label = "Actions" >
< Menu.Item >
< Label />
< Menu.ItemIndicator />
</ Menu.Item >
< Separator />
< Menu.Section aria-label = "Section" >
< Menu.Item >
< Label />
< Menu.SubmenuIndicator />
</ Menu.Item >
</ Menu.Section >
</ Menu >
);
< Menu aria-label = "Actions" className = "w-60 rounded-xl border border-border p-2" >
< Menu.Item id = "new" textValue = "New file" >
< Label >New file</ Label >
</ Menu.Item >
</ Menu >
@layer components {
.menu {
@apply gap-1 rounded-xl border border-border p-2;
}
}
PeakUI follows the BEM methodology, so variants and states are plain class names you can target.
The Menu component uses these CSS classes (view source styles ):
.menu - Inline menu container
.menu-item - Menu item
.menu-section - Menu section
.menu-item__indicator - Selection indicator of an item
.menu-item__indicator--submenu - Submenu indicator of an item
.menu-item--default
.menu-item--danger
[data-slot="menu"]
[data-slot="menu-item"]
[data-slot="menu-section"]
[data-slot="menu-item-indicator"]
[data-slot="menu-item-indicator--checkmark"]
[data-slot="menu-item-indicator--dot"]
[data-slot="submenu-indicator"]
The component supports both CSS pseudo-classes and data attributes:
Selection mode : [data-selection-mode] on the menu
Hover : :hover or [data-hovered="true"] on an item
Focus : :focus-visible or [data-focus-visible="true"] on an item
Pressed : :active or [data-pressed="true"] on an item
Selected : [aria-checked="true"], [aria-selected="true"] or [data-selected="true"] on an item; [data-visible] on its indicator
Disabled : [data-disabled="true"] on an item
Submenu : [data-has-submenu="true"] on an item
Prop Type Default Description selectionMode"single" | "multiple" | "none""none"Whether single or multiple selection is enabled selectedKeysIterable<Key>- The currently selected keys (controlled) defaultSelectedKeysIterable<Key>- The initial selected keys (uncontrolled) onSelectionChange(keys: Selection) => void- Handler called when the selection changes disabledKeysIterable<Key>- Keys of disabled items onAction(key: Key) => void- Handler called when an item is activated classNamestring | ((values) => string)- Additional CSS classes childrenReactNode- Menu content ...restMenuProps<T>- React Aria Menu attributes
Prop Type Default Description idKey- Unique identifier for the item textValuestring- Text content of the item for typeahead variant"default" | "danger""default"Visual variant of the item isDisabledboolean- Whether the item is disabled hrefstring- Renders the item as a link to this URL classNamestring- Additional CSS classes childrenReactNode | RenderFunction- Item content or render function ...restMenuItemProps- React Aria MenuItem attributes
Prop Type Default Description classNamestring- Additional CSS classes childrenReactNode- Section content ...restMenuSectionProps- React Aria MenuSection attributes
Prop Type Default Description type"checkmark" | "dot""checkmark"Type of indicator to display classNamestring- Additional CSS classes childrenReactNode | RenderFunction- Custom indicator content or render function
Prop Type Default Description classNamestring- Additional CSS classes childrenReactNode- Custom indicator content