MenuButton
A button that opens a menu: Button with aria-haspopup="menu", aria-expanded and a trailing chevron. Same appearances, sizes, type="button" default and decorative icon slot as Button. Without a label (only an icon and/or the chevron) it has no minimum width, and it warns in development when it also has no aria-label, aria-labelledby or title.
as renders another element or component with correctly typed props, as on Button.
Use it as the child of Menu.Trigger, which supplies id, aria-expanded, aria-controls, the open/keyboard handlers and the ref. A defined aria-haspopup/aria-expanded prop wins over the built-in "menu" and expanded defaults, so the trigger's live state always wins; an undefined or null one (a wrapper forwarding its own unset props) keeps the defaults. On its own (no Menu.Trigger, no expanded) it reports aria-expanded="false".
Examples
Default
export const Default: Story = {};Primary
export const Primary: Story = {
args: {
appearance: 'primary',
},
};With Icon
export const WithIcon: Story = {
args: {
children: 'Settings',
icon: <GearIcon />,
},
};Icon Only
export const IconOnly: Story = {
args: {
children: undefined,
icon: <GearIcon />,
'aria-label': 'Settings',
},
};With Menu
export const WithMenu: Story = {
render: (args) => (
<Menu>
<Menu.Trigger>
<MenuButton {...args} />
</Menu.Trigger>
<Menu.Popover>
<Menu.Item onClick={fn()}>Edit</Menu.Item>
<Menu.Item onClick={fn()}>Duplicate</Menu.Item>
<Menu.Divider />
<Menu.Item onClick={fn()}>Delete</Menu.Item>
</Menu.Popover>
</Menu>
),
};Disabled
export const Disabled: Story = {
args: {
disabled: true,
},
};Custom Menu Icon
export const CustomMenuIcon: Story = {
args: {
menuIcon: <span className="text-wave-caption-1">▾</span>,
},
};Shapes
export const Shapes: Story = {
argTypes: {
shape: { control: false },
},
render: (args) => (
<div className="flex items-center gap-2">
<MenuButton {...args} shape="rounded">
rounded
</MenuButton>
<MenuButton {...args} shape="circular">
circular
</MenuButton>
<MenuButton {...args} shape="square">
square
</MenuButton>
</div>
),
};Props
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
appearance | 'primary' | 'outline' | 'subtle' | 'transparent' | No | 'outline' | Visual style variant. |
size | 'extra-small' | 'small' | 'medium' | 'large' | 'extra-large' | No | 'medium' | Size affecting height, padding and font size. |
shape | 'circular' | 'square' | 'rounded' | No | 'rounded' | Corner shape, as on Button. |
icon | Slot<'span'> | No | Icon slot rendered before the label. Decorative: it renders with | |
menuIcon | Slot<'span'> | No | Custom menu indicator rendered after the label, in place of the default chevron. Decorative ( | |
expanded | boolean | No | false | Whether the associated menu is open ( |
disabledFocusable | boolean | No | false | Marks the menu button unavailable but keeps it focusable and in the tab order (see |
as | React.ElementType | No | 'button' | Render as a different element or component (its props are type-checked). |
Any other prop is passed to the element it renders (HTMLButtonElement).
Stable class names
| Part | Class |
|---|---|
root | wave-menu-button |
icon | wave-menu-button__icon |
menuIcon | wave-menu-button__menu-icon |