Skip to content

Split button

Expressive

A primary action beside a trailing button that opens a menu of related actions.

import { SplitButton } from '@windmorph/react';

Props

By name or description, across the 24 props below

SplitButton 24 props

  • varianttype "outlined" | "filled" | "elevated" | "tonal"default "filled"

    The M3 style of both buttons: filled, tonal, outlined or elevated.

  • sizetype "xs" | "sm" | "md" | "lg" | "xl"default "sm"

    Height, padding and label size of both buttons, from extra small to extra large.

  • leadingIcontype ReactElement<unknown, string | JSXElementConstructor<any>>

    Icon before the label, or on its own with leadingLabel. Hidden from assistive tech.

  • menutype ReactElement<MenuProps, string | JSXElementConstructor<any>>

    The <Menu> the trailing button opens, 4px below it and aligned with its end edge unless the menu sets its own placement or offset. Leave it out to open something else: the trailing button then takes an enclosing trigger (a DialogTrigger, a RichTooltipTrigger, …), or reports presses through onTrailingPress and onOpenChange.

  • trailingReftype Ref<HTMLButtonElement>

    Ref to the trailing button, e.g. to anchor a custom overlay to it.

  • opentype boolean

    Whether the trailing button's menu or overlay is open (controlled).

  • defaultOpentype booleandefault false

    Whether the menu starts open (uncontrolled).

  • disabledtype booleandefault false

    Disables both buttons.

  • childrentype ReactNode

    The leading button's label.

  • leadingLabeltype string

    Accessible name of an icon-only leading button.

  • typetype "button" | "submit" | "reset"default "button"

    The leading button's type, e.g. submit to send the form it's in.

  • reftype Ref<HTMLDivElement>

    Ref to the root element.

  • reltype string

    The leading link's rel, e.g. noopener.

  • hreftype string

    Makes the leading button a link (<a>) to this URL.

  • targettype HTMLAttributeAnchorTarget

    The leading link's target, e.g. _blank.

Events

  • onTrailingPresstype ((event: PressEvent) => void)

    Called when the trailing button is pressed. Without a menu or trigger it also toggles open.

  • onOpenChangetype ((open: boolean) => void)

    Called with the new state when the menu or overlay opens or closes.

Text

  • labelstype Partial<SplitButtonLabels>

    Words the split button announces, with English defaults. A LabelsProvider sets them for the whole app.

Also accepts the root element's HTML attributes (id, data-*, event handlers).

Tokens

M3's component tokens as CSS variables. Each is unset until you set it, on :root, a theme or any ancestor, and falls back to the default shown. The root carries data-variant (and data-size where it has sizes), which picks the variables that apply. See Component tokens in the Customisation guide.

Split button tokens (md-comp-split-button)
VariableDefaultPaintsCompose
Xs (size)
--md-comp-split-button-xsmall-container-shapevar(--md-sys-shape-corner-full)The outer corners of both halves: full, at most half the height.SplitButtonXSmallTokens.ContainerShape
Sm (size)
--md-comp-split-button-small-container-shapevar(--md-sys-shape-corner-full)The outer corners of both halves: full, at most half the height.SplitButtonSmallTokens.ContainerShape
Md (size)
--md-comp-split-button-medium-container-shapevar(--md-sys-shape-corner-full)The outer corners of both halves: full, at most half the height.SplitButtonMediumTokens.ContainerShape
Lg (size)
--md-comp-split-button-large-container-shapevar(--md-sys-shape-corner-full)The outer corners of both halves: full, at most half the height.SplitButtonLargeTokens.ContainerShape
Xl (size)
--md-comp-split-button-xlarge-container-shapevar(--md-sys-shape-corner-full)The outer corners of both halves: full, at most half the height.SplitButtonXLargeTokens.ContainerShape

Spec status

Built to the M3 Expressive split button spec. Each item of its variants and configurations links to a live example; where the M3 Expressive column of the spec differs from the original M3 one, it wins.

  • Split button

    Built

    Variant · Basic

  • Color: elevated, filled, tonal, outlined

    Built

    Configuration · Variants

  • Size: XS, S, M, L, XL

    Built

    Configuration · Sizes

  • Leading button: label and icon, label, or icon

    Built

    Use case · Basic, Sizes, Icon

  • Links

    Extension

    href makes the leading button a link.

  • Custom overlays

    Extension

    Without menu, the trailing button joins an enclosing DialogTrigger, SheetTrigger or RichTooltipTrigger, or calls onTrailingPress with trailingRef to anchor an overlay of your own.

Bundle size

Gzipped, as published: the component and the library code it imports. React, React Aria, Motion and the other dependencies aren't counted, and your bundler's minifier makes it smaller still. CI fails a change that grows it past its budget.

  • SplitButton: 18.9 kB

M3 Expressive specs

Sizes
xs, sm, md, lg, xl
Variants
filled, elevated, tonal, outlined

Differences from Compose

  • Variants are filled | tonal | outlined | elevated — Compose has no text split button. Sizes run xs–xl; colours and elevation are shared with Button.
  • The two halves sit 2px apart, each at least 48px wide, with full outer corners. Inner corners are 4 / 4 / 4 / 8 / 12px and change to 8 / 12 / 12 / 20 / 20px when hovered, keyboard-focused or pressed (Compose uses only the pressed tokens). The menu opens 4px below, aligned with the trailing button's end edge, even against the edge of the window (the menu's containerPadding is 0).
  • With a mouse the menu opens when the press is released, not on pointer down as React Aria's menu triggers do, so the trailing button's pressed shape shows while it's held. Keyboard and touch are unchanged.
  • Under reduced motion the chevron turns and the corners change without animating.
  • While its menu is open the trailing button becomes a circle with a persistent 10% layer of its content colour, drawn by its state layer and added to any hover or focus layer.
  • The chevron turns over inwards (towards the leading button) on the standard scheme's fast spatial spring, whatever the active scheme, as the spec asks. At rest it sits −1 / −1 / −2 / −3 / −6px from the centre, a logical offset that mirrors in RTL, and it can't be replaced.
  • The per-size asymmetric corners and optical offset are not expressible through the public Button / IconButton, so the halves build on ButtonBase; the leading half is shielded from the menu's trigger context.