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
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
disabled | boolean | No | false | Disables both buttons. A half's own |
disabledFocusable | boolean | No | false | Makes both halves unavailable but focusable (see |
icon | Slot<'span'> | No | Icon of the primary action, decorative ( | |
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. |
menuIcon | Slot<'span'> | No | Replaces the chevron of the menu half (decorative, | |
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 |
onClick | React.MouseEventHandler<HTMLButtonElement> | No | Click handler for the primary action button. | |
onMenuClick | React.MouseEventHandler<HTMLButtonElement> | No | Click handler for the menu (chevron) button. | |
menuButtonLabel | string | null | No | 'More options' | Accessible name of the menu button (it shows only a chevron). Localize it. |
menuButtonProps | SplitButtonMenuButtonProps | No | Props for the menu button: | |
primaryActionButtonProps | SplitButtonPrimaryActionButtonProps | No | Props for the primary action button ( | |
ref | React.Ref<HTMLDivElement> | No | Ref to the wrapping |
Any other prop is passed to the element it renders (HTMLDivElement).
Stable class names
| Part | Class |
|---|---|
root | wave-split-button |
primaryActionButton | wave-split-button__primary-action-button |
menuButton | wave-split-button__menu-button |
icon | wave-split-button__icon |
menuIcon | wave-split-button__menu-icon |