Skip to content

Material 3

Components

Split button

Split buttons open a menu to give people more options related to an action.

New emailToali.connors@example.comBrunch this weekend?

Hi Ali, are you free on Sunday? There’s a new place by the lake that I’d like to try, and they take bookings until Friday.

A split button is two buttons side by side: a leading button for an action, and a trailing button that opens a menu of options related to that action.

Use one for an action that has a set of related options. For an action alone, use a button, and to group several related actions, a button group.

A split button is composed of these parts:

PartUse
SplitButtonLeadingThe leading button, for the action
SplitButtonTrailingThe trailing button, for the menu icon. Wrap it in a MenuTrigger to open a menu.
import {
  Menu,
  MenuItem,
  MenuPopover,
  SplitButton,
  SplitButtonLeading,
  SplitButtonTrailing,
} from '@material-web/react'
import { MenuTrigger } from 'react-aria-components'

Basic split button

Put a SplitButtonLeading and then a SplitButtonTrailing in a SplitButton.

import {
  Menu,
  MenuItem,
  MenuPopover,
  SplitButton,
  SplitButtonLeading,
  SplitButtonTrailing,
} from '@material-web/react'
import { MenuTrigger } from 'react-aria-components'

export default function Basic() {
  return (
    <SplitButton variant="tonal" size="m">
      <SplitButtonLeading>Reply</SplitButtonLeading>
      <MenuTrigger>
        <SplitButtonTrailing aria-label="More reply options" />
        <MenuPopover>
          <Menu>
            <MenuItem>Reply all</MenuItem>
            <MenuItem>Forward</MenuItem>
          </Menu>
        </MenuPopover>
      </MenuTrigger>
    </SplitButton>
  )
}

Set variant and size on the SplitButton. Each button takes its own props, such as onPress and isDisabled.

The SplitButton comes in four variants. Set variant on the SplitButton to elevated, filled (the default), tonal or outlined. They are the same as a button's, without text.

import {
  Menu,
  MenuItem,
  MenuPopover,
  SplitButton,
  SplitButtonLeading,
  SplitButtonTrailing,
} from '@material-web/react'
import { MenuTrigger } from 'react-aria-components'

const variants = ['elevated', 'filled', 'tonal', 'outlined'] as const

export default function Variants() {
  return (
    <>
      {variants.map((variant) => (
        <SplitButton key={variant} variant={variant}>
          <SplitButtonLeading>Reply</SplitButtonLeading>
          <MenuTrigger>
            <SplitButtonTrailing aria-label={`More reply options, ${variant}`} />
            <MenuPopover>
              <Menu>
                <MenuItem>Reply all</MenuItem>
                <MenuItem>Forward</MenuItem>
              </Menu>
            </MenuPopover>
          </MenuTrigger>
        </SplitButton>
      ))}
    </>
  )
}

Disable each button with its own isDisabled. A disabled button cannot be pressed or focused.

import { SplitButton, SplitButtonLeading, SplitButtonTrailing } from '@material-web/react'

export default function Disabled() {
  return (
    <>
      <SplitButton>
        <SplitButtonLeading isDisabled>Reply</SplitButtonLeading>
        <SplitButtonTrailing aria-label="More reply options" isDisabled />
      </SplitButton>
      <SplitButton variant="outlined">
        <SplitButtonLeading isDisabled>Reply</SplitButtonLeading>
        <SplitButtonTrailing aria-label="More reply options" isDisabled />
      </SplitButton>
    </>
  )
}

Elevated split button

An elevated split button is a tonal one with a shadow. To avoid overusing shadows, use it only when the button needs visual separation from a visually prominent background.

import {
  Menu,
  MenuItem,
  MenuPopover,
  SplitButton,
  SplitButtonLeading,
  SplitButtonTrailing,
} from '@material-web/react'
import { MenuTrigger } from 'react-aria-components'

export default function Elevated() {
  return (
    <SplitButton variant="elevated">
      <SplitButtonLeading>Reply</SplitButtonLeading>
      <MenuTrigger>
        <SplitButtonTrailing aria-label="More reply options" />
        <MenuPopover>
          <Menu>
            <MenuItem>Reply all</MenuItem>
            <MenuItem>Forward</MenuItem>
          </Menu>
        </MenuPopover>
      </MenuTrigger>
    </SplitButton>
  )
}

Filled split button

A filled split button has the most visual impact of the four. Use it for an important, final action that completes a flow.

import {
  Menu,
  MenuItem,
  MenuPopover,
  SplitButton,
  SplitButtonLeading,
  SplitButtonTrailing,
} from '@material-web/react'
import { MenuTrigger } from 'react-aria-components'

export default function Filled() {
  return (
    <SplitButton variant="filled">
      <SplitButtonLeading>Reply</SplitButtonLeading>
      <MenuTrigger>
        <SplitButtonTrailing aria-label="More reply options" />
        <MenuPopover>
          <Menu>
            <MenuItem>Reply all</MenuItem>
            <MenuItem>Forward</MenuItem>
          </Menu>
        </MenuPopover>
      </MenuTrigger>
    </SplitButton>
  )
}

Tonal split button

A tonal split button suits a lower-priority action that needs slightly more emphasis than an outline gives.

import {
  Menu,
  MenuItem,
  MenuPopover,
  SplitButton,
  SplitButtonLeading,
  SplitButtonTrailing,
} from '@material-web/react'
import { MenuTrigger } from 'react-aria-components'

export default function Tonal() {
  return (
    <SplitButton variant="tonal">
      <SplitButtonLeading>Reply</SplitButtonLeading>
      <MenuTrigger>
        <SplitButtonTrailing aria-label="More reply options" />
        <MenuPopover>
          <Menu>
            <MenuItem>Reply all</MenuItem>
            <MenuItem>Forward</MenuItem>
          </Menu>
        </MenuPopover>
      </MenuTrigger>
    </SplitButton>
  )
}

Outlined split button

An outlined split button is for medium-emphasis actions: ones that are important, but are not the primary action in a product.

import {
  Menu,
  MenuItem,
  MenuPopover,
  SplitButton,
  SplitButtonLeading,
  SplitButtonTrailing,
} from '@material-web/react'
import { MenuTrigger } from 'react-aria-components'

export default function Outlined() {
  return (
    <SplitButton variant="outlined">
      <SplitButtonLeading>Reply</SplitButtonLeading>
      <MenuTrigger>
        <SplitButtonTrailing aria-label="More reply options" />
        <MenuPopover>
          <Menu>
            <MenuItem>Reply all</MenuItem>
            <MenuItem>Forward</MenuItem>
          </Menu>
        </MenuPopover>
      </MenuTrigger>
    </SplitButton>
  )
}

Icons

Write an icon as a child of the leading button, before or after its label. An Icon is sized to the button. Any icon works: Icon, an icon from an SVG library, or your own component. Give an icon that is not an Icon the size listed under Sizes. See Composition.

The leading button can hold an icon alone. It then has no visible text, so set an aria-label.

import {
  Icon,
  Menu,
  MenuItem,
  MenuPopover,
  SplitButton,
  SplitButtonLeading,
  SplitButtonTrailing,
} from '@material-web/react'
import { MenuTrigger } from 'react-aria-components'

export default function WithIcon() {
  return (
    <>
      <SplitButton variant="tonal">
        <SplitButtonLeading>
          <Icon name="reply" />
          Reply
        </SplitButtonLeading>
        <MenuTrigger>
          <SplitButtonTrailing aria-label="More reply options" />
          <MenuPopover>
            <Menu>
              <MenuItem>Reply all</MenuItem>
              <MenuItem>Forward</MenuItem>
            </Menu>
          </MenuPopover>
        </MenuTrigger>
      </SplitButton>
      <SplitButton variant="tonal">
        <SplitButtonLeading aria-label="Edit">
          <Icon name="edit" />
        </SplitButtonLeading>
        <MenuTrigger>
          <SplitButtonTrailing aria-label="More edit options" />
          <MenuPopover>
            <Menu>
              <MenuItem>Rename</MenuItem>
              <MenuItem>Duplicate</MenuItem>
            </Menu>
          </MenuPopover>
        </MenuTrigger>
      </SplitButton>
    </>
  )
}

The trailing button has its own icon and takes no children.

Trailing button

In a MenuTrigger, the trailing button gets its onPress, aria-haspopup, aria-expanded and aria-controls from the trigger. While the menu is open, its icon turns 180° and its inner corner becomes round.

To open anything other than a menu, set those four props yourself. aria-expanded is what turns the icon and rounds the inner corner.

import { SplitButton, SplitButtonLeading, SplitButtonTrailing } from '@material-web/react'
import { useId, useState } from 'react'

export default function Expanded() {
  const [isOpen, setOpen] = useState(false)
  const panelId = useId()
  return (
    <div className="flex flex-col items-center gap-space-200">
      <SplitButton variant="outlined">
        <SplitButtonLeading>Export</SplitButtonLeading>
        <SplitButtonTrailing
          aria-label="More export options"
          aria-expanded={isOpen}
          aria-controls={panelId}
          onPress={() => setOpen(!isOpen)}
        />
      </SplitButton>
      <p id={panelId} hidden={!isOpen} className="m-0 text-body-md text-on-surface-variant">
        Exports as PDF, at the size of the page.
      </p>
    </div>
  )
}

Handling presses

Handle a press on the leading button with its onPress. In a MenuTrigger, a press on the trailing button opens the menu: handle a press on an item with onAction on the Menu, which is called with the item's id.

No action yet
import {
  Menu,
  MenuItem,
  MenuPopover,
  SplitButton,
  SplitButtonLeading,
  SplitButtonTrailing,
} from '@material-web/react'
import { useState } from 'react'
import { MenuTrigger } from 'react-aria-components'

export default function Press() {
  const [action, setAction] = useState<string>()
  return (
    <>
      <SplitButton>
        <SplitButtonLeading onPress={() => setAction('reply')}>Reply</SplitButtonLeading>
        <MenuTrigger>
          <SplitButtonTrailing aria-label="More reply options" />
          <MenuPopover>
            <Menu onAction={(id) => setAction(String(id))}>
              <MenuItem id="reply-all">Reply all</MenuItem>
              <MenuItem id="forward">Forward</MenuItem>
            </Menu>
          </MenuPopover>
        </MenuTrigger>
      </SplitButton>
      <span className="text-body-md text-on-surface-variant">
        {action ? `Last action: ${action}` : 'No action yet'}
      </span>
    </>
  )
}

Each button takes the same press events as a Button. See Handling presses.

Loading

Set isPending on the SplitButtonLeading while its action is in progress, as on a button. A pending leading button shows a loading indicator in place of its label and icon, sized to the button. It keeps its size and colors, so the layout around it does not shift.

import {
  Menu,
  MenuItem,
  MenuPopover,
  SplitButton,
  SplitButtonLeading,
  SplitButtonTrailing,
} from '@material-web/react'
import { useState } from 'react'
import { MenuTrigger } from 'react-aria-components'

export default function Loading() {
  const [isSending, setSending] = useState(false)
  const send = async () => {
    setSending(true)
    await new Promise((resolve) => setTimeout(resolve, 3000))
    setSending(false)
  }
  return (
    <SplitButton size="m">
      <SplitButtonLeading isPending={isSending} onPress={send}>
        Send
      </SplitButtonLeading>
      <MenuTrigger>
        <SplitButtonTrailing aria-label="More send options" />
        <MenuPopover>
          <Menu>
            <MenuItem>Schedule send</MenuItem>
            <MenuItem>Save as draft</MenuItem>
          </Menu>
        </MenuPopover>
      </MenuTrigger>
    </SplitButton>
  )
}
  • Presses: A pending leading button ignores presses and shows no hover. As a submit button, it does not submit its form, and as a link, it does not navigate. The trailing button still opens the menu.
  • Focus: It keeps the focus, so a keyboard user stays on it while the action runs.
  • Children: Its children are hidden while it is pending. See Pending content.

Color

A variant sets the colors of both buttons. To use other color roles, pass their classes in the className of each button: a container color, and the on-color of that container for the label and the icons.

import {
  Menu,
  MenuItem,
  MenuPopover,
  SplitButton,
  SplitButtonLeading,
  SplitButtonTrailing,
} from '@material-web/react'
import { MenuTrigger } from 'react-aria-components'

export default function Colors() {
  return (
    <SplitButton variant="tonal">
      <SplitButtonLeading className="bg-tertiary-container text-on-tertiary-container">
        Reply
      </SplitButtonLeading>
      <MenuTrigger>
        <SplitButtonTrailing
          className="bg-tertiary-container text-on-tertiary-container"
          aria-label="More reply options"
        />
        <MenuPopover>
          <Menu>
            <MenuItem>Reply all</MenuItem>
            <MenuItem>Forward</MenuItem>
          </Menu>
        </MenuPopover>
      </MenuTrigger>
    </SplitButton>
  )
}

Sizes

For larger or smaller split buttons, set size on the SplitButton to xs, s (the default), m, l or xl.

SizeHeightLeading iconTrailing button
xs32dp20dp48dp wide
s40dp20dp48dp wide
m56dp24dp56dp wide
l96dp32dp96dp wide
xl136dp40dp136dp wide
import {
  Menu,
  MenuItem,
  MenuPopover,
  SplitButton,
  SplitButtonLeading,
  SplitButtonTrailing,
} from '@material-web/react'
import { MenuTrigger } from 'react-aria-components'

const sizes = ['xs', 's', 'm', 'l', 'xl'] as const

export default function Sizes() {
  return (
    <>
      {sizes.map((size) => (
        <SplitButton key={size} size={size}>
          <SplitButtonLeading>Reply</SplitButtonLeading>
          <MenuTrigger>
            <SplitButtonTrailing aria-label={`More reply options, ${size}`} />
            <MenuPopover>
              <Menu>
                <MenuItem>Reply all</MenuItem>
                <MenuItem>Forward</MenuItem>
              </Menu>
            </MenuPopover>
          </MenuTrigger>
        </SplitButton>
      ))}
    </>
  )
}

The leading button is as tall as a Button of the same size, with its label in the same type style. For xs and s, the trailing button is at least 48dp wide, wider than it is tall.

Rendering non-native buttons

Set elementType on the SplitButtonLeading to render it as an element other than a <button>. The element gets the button role and a tab stop, as on a button.

Set elementType="a" on the SplitButtonLeading to render it as a link, with href, target and rel. The browser follows it as a native link, without a client-side router. To follow it through a router, see Third-party routing library.

Read the spec
import {
  Icon,
  Menu,
  MenuItem,
  MenuPopover,
  SplitButton,
  SplitButtonLeading,
  SplitButtonTrailing,
} from '@material-web/react'
import { MenuTrigger } from 'react-aria-components'

const spec = 'https://m3.material.io/components/split-button'

export default function LinkSplitButton() {
  return (
    <SplitButton variant="elevated">
      <SplitButtonLeading
        elementType="a"
        href={`${spec}/overview`}
        target="_blank"
        rel="noreferrer"
      >
        Read the spec
        <Icon name="open_in_new" />
      </SplitButtonLeading>
      <MenuTrigger>
        <SplitButtonTrailing aria-label="More pages of the spec" />
        <MenuPopover>
          <Menu>
            <MenuItem href={`${spec}/specs`} target="_blank" rel="noreferrer">
              Specs
            </MenuItem>
            <MenuItem href={`${spec}/guidelines`} target="_blank" rel="noreferrer">
              Guidelines
            </MenuItem>
          </Menu>
        </MenuPopover>
      </MenuTrigger>
    </SplitButton>
  )
}

Note: The trailing button cannot be a link. elementType="a" on a SplitButtonTrailing is a type error.

Customization

Pass classes in className to restyle one split button: on the SplitButton for the element around the two buttons, and on each button for the button itself. A class of yours replaces the component's own class for the same property. See Styling for the classes, the states and the theme.

import {
  Icon,
  Menu,
  MenuItem,
  MenuPopover,
  SplitButton,
  SplitButtonLeading,
  SplitButtonTrailing,
} from '@material-web/react'
import { MenuTrigger } from 'react-aria-components'

export default function Custom() {
  return (
    <SplitButton variant="tonal" className="density-2">
      <SplitButtonLeading>
        {({ isHovered }) => (
          <>
            <Icon name="bookmark" className={isHovered ? 'icon-filled' : undefined} />
            Save
          </>
        )}
      </SplitButtonLeading>
      <MenuTrigger>
        <SplitButtonTrailing aria-label="More save options" />
        <MenuPopover>
          <Menu>
            <MenuItem>Save to a list</MenuItem>
            <MenuItem>Save and share</MenuItem>
          </Menu>
        </MenuPopover>
      </MenuTrigger>
    </SplitButton>
  )
}
  • Density: Add density-1, density-2 or density-3 to the SplitButton, or to an element around it. Each step makes both buttons 4dp shorter. See Density.
  • States: Style a state of either button with its variant, such as hover: or pressed:. In your own CSS, select the same states on either button by their data attributes: data-hovered, data-pressed, data-focused, data-focus-visible and data-disabled. See States.
  • Functions: Pass a function as the children of a SplitButtonLeading to render them from the button's state: isHovered, isPressed, isFocused, isFocusVisible, isDisabled and isPending. The className and style of either button can be functions of the same state. See Children as a function.
  • Every split button: To restyle all the split buttons at once, change the theme.

Limitations

A leading button rendered as an <a> keeps the button role, so assistive technology announces it as a button and not as a link. A disabled one has no href.

Disabled buttons

A disabled button cannot be focused and reports no hover, so it shows no tooltip.

Pending content

A pending leading button shows only its loading indicator. Children written for the pending state, such as a Sending… label, are hidden too. For a button that shows other content while pending, build a complex button.