Skip to content

MenuButton

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

NameTypeRequiredDefaultDescription
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.

iconSlot<'span'>No

Icon slot rendered before the label. Decorative: it renders with aria-hidden="true" (a slot object can override it). A menu button without a label (only the icon and/or the indicator) needs aria-label, aria-labelledby or title.

menuIconSlot<'span'>No

Custom menu indicator rendered after the label, in place of the default chevron. Decorative (aria-hidden="true" unless a slot object overrides it). false hides the indicator, as does any value that renders nothing (true, '', an empty array or Fragment, e.g. from menuIcon={cond && <X />}); null/undefined keep the default chevron. A <button> or Button element, or a slot object whose as is one, is not nested inside the menu button: its children become the indicator (the chevron when they render nothing), its props (icon included) are dropped, and a development warning says so.

expandedbooleanNofalse

Whether the associated menu is open (aria-expanded). Without it the button reports aria-expanded="false", so a menu button always exposes its state; leave it unset when the button is wrapped in Menu.Trigger, which supplies aria-expanded itself and wins.

disabledFocusablebooleanNofalse

Marks the menu button unavailable but keeps it focusable and in the tab order (see Button.disabledFocusable): aria-disabled="true", data-disabled and data-disabled-focusable instead of the native disabled attribute. Clicks, Enter and Space are prevented and do not call onClick; other keys still reach onKeyDown, and Menu.Trigger does not open its menu from an aria-disabled trigger. Wins over disabled when both are set. In a Toolbar it stays in the arrow-key order.

asReact.ElementTypeNo'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

PartClass
rootwave-menu-button
iconwave-menu-button__icon
menuIconwave-menu-button__menu-icon