Skip to content

SplitButton

SplitButton

A primary action button joined to a menu button (chevron), e.g. Save + "Save as…" options. Both halves are Buttons with the shared appearances and sizes, inside a role="group" wrapper.

- ref, className, style, aria-label and other props go to the group; aria-describedby is routed to the primary button (so a Tooltip around the SplitButton describes the action).
- primaryActionButtonProps / menuButtonProps reach the two buttons; the menu button is named by menuButtonLabel (default 'More options').
- The menu button is at least 24×24 px at every size, so an extra-small SplitButton is 24px tall.
- icon/iconPosition belong to the primary action; menuIcon replaces the chevron, which the menu half always shows (a menuIcon that renders nothing keeps it).
- disabledFocusable keeps both halves focusable while unavailable; Menu.Trigger does not open its menu from an aria-disabled menu half.

Examples

Default

export const Default: Story = {};

Primary

export const Primary: Story = {
  args: {
    appearance: 'primary',
  },
};

Disabled

export const Disabled: Story = {
  args: {
    disabled: true,
  },
};

With Icon

export const WithIcon: Story = {
  args: {
    icon: <SaveIcon />,
  },
};

Custom Menu Icon

export const CustomMenuIcon: Story = {
  args: {
    menuIcon: <MoreIcon />,
  },
};

Localized Menu Label

export const LocalizedMenuLabel: Story = {
  args: {
    children: 'Speichern',
    'aria-label': 'Speicheroptionen',
    menuButtonLabel: 'Weitere Optionen',
  },
};

With Menu

export const WithMenu: Story = {
  render: (args) => (
    <Menu>
      <Menu.Trigger>
        {(triggerProps) => <SplitButton {...args} menuButtonProps={triggerProps} />}
      </Menu.Trigger>
      <Menu.Popover>
        <Menu.Item onClick={fn()}>Save as…</Menu.Item>
        <Menu.Item onClick={fn()}>Save a copy</Menu.Item>
        <Menu.Divider />
        <Menu.Item onClick={fn()}>Save all</Menu.Item>
      </Menu.Popover>
    </Menu>
  ),
};

Sizes

export const Sizes: Story = {
  argTypes: {
    size: { control: false },
  },
  render: (args) => (
    <div className="flex items-center gap-2">
      <SplitButton {...args} size="extra-small" aria-label="Extra small save options" />
      <SplitButton {...args} size="small" aria-label="Small save options" />
      <SplitButton {...args} size="medium" aria-label="Medium save options" />
      <SplitButton {...args} size="large" aria-label="Large save options" />
    </div>
  ),
};

Shapes

export const Shapes: Story = {
  argTypes: {
    shape: { control: false },
  },
  render: (args) => (
    <div className="flex items-center gap-2">
      <SplitButton {...args} shape="rounded" aria-label="Rounded save options" />
      <SplitButton {...args} shape="circular" aria-label="Circular save options" />
      <SplitButton {...args} shape="square" aria-label="Square save options" />
    </div>
  ),
};

Named By Primary Action

export const NamedByPrimaryAction: Story = {
  args: {
    menuButtonLabel: null,
  },
};

Props

NameTypeRequiredDefaultDescription
disabledbooleanNofalse

Disables both buttons. A half's own disabled (primaryActionButtonProps, menuButtonProps) disables only that half.

disabledFocusablebooleanNofalse

Makes both halves unavailable but focusable (see Button.disabledFocusable): each half renders aria-disabled="true", data-disabled and data-disabled-focusable, stays in the tab order, and neither onClick nor the menu opens. A half's own disabledFocusable (in primaryActionButtonProps/menuButtonProps) affects only that half. For each half, focusable-disabled wins over natively disabled: the half is focusable-disabled when the root's or its own disabledFocusable is set; otherwise it is natively disabled when the root's or its own disabled is set.

iconSlot<'span'>No

Icon of the primary action, decorative (aria-hidden). For an icon-only primary action pass primaryActionButtonProps={{ 'aria-label': '…' }}.

iconPosition'before' | 'after'No'before'

Where the primary action's icon renders: before its label (the inline start) or after it. Has no effect on an icon-only primary action. The menu half is not affected.

menuIconSlot<'span'>No

Replaces the chevron of the menu half (decorative, aria-hidden). The menu half always shows an indicator: null and undefined keep the default chevron, and so does a value that renders nothing (false, '', an empty array), which also logs a development warning. Unlike MenuButton.menuIcon, a value that renders nothing does not hide the indicator. A <button> or Button element, or a slot object whose as is one, is not nested inside the menu half: its children become the glyph (the chevron when they render nothing), its props (icon included) are dropped, and a development warning says so.

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 of the whole split button (Fluent's shape): the outer corners of the two halves are rounded (rounded, the default radius), fully round (circular) or square, and the corners where they meet stay square. Renders data-shape while it is set, on the group and on both halves.

onClickReact.MouseEventHandler<HTMLButtonElement>No

Click handler for the primary action button.

onMenuClickReact.MouseEventHandler<HTMLButtonElement>No

Click handler for the menu (chevron) button.

menuButtonLabelstring | nullNo'More options'

Accessible name of the menu button (it shows only a chevron). Localize it. null leaves the built-in name out: the menu half is then named by the primary action's name (it points aria-labelledby at the primary button), which is how Fluent names it. An aria-label or aria-labelledby in menuButtonProps wins over both.

menuButtonPropsSplitButtonMenuButtonPropsNo

Props for the menu button: aria-expanded, aria-controls, id, handlers (onKeyDown for ArrowDown/ArrowUp), ref for focus restoration, … Pass the render-prop props of Menu.Trigger here to open a Menu from the chevron.

primaryActionButtonPropsSplitButtonPrimaryActionButtonPropsNo

Props for the primary action button (ref, title, handlers, …).

refReact.Ref<HTMLDivElement>No

Ref to the wrapping role="group" element.

Any other prop is passed to the element it renders (HTMLDivElement).

Stable class names

PartClass
rootwave-split-button
primaryActionButtonwave-split-button__primary-action-button
menuButtonwave-split-button__menu-button
iconwave-split-button__icon
menuIconwave-split-button__menu-icon