Search
MaterialComponentsDocs
Components overviewApp barBadgeButtonsButton groupButtonExtended FABFAB menuFABIcon buttonSplit buttonCardCarouselCheckboxChipsDate & time pickersDate pickerTime pickerDialogDividerListLoading & progressLoading indicatorProgressMenuNavigationNavigation barNavigation drawerNavigation railRadio buttonsSearchSelectSheetsBottom sheetSide sheetSliderSnackbarSwitchTabsText fieldToolbarTooltip

Split button

A primary action and more possibilities. Open the trailing menu to try the alternatives.

Buy nowSave for laterAdd to list
FactoryWeb ComponentsReactVueSvelteSolidJS
PublishedUpdated

A split button pairs one action with a button that opens more choices: Save, with "Save a copy" behind the chevron; Send, with "Schedule send". Use it when one action is the obvious default and the rest are variations of it; for unrelated choices use a menu, for alternatives of equal weight a button group.

Usage

The leading button does the common thing; the trailing one opens a menu of items, and its chevron turns over while the menu is open.

Vanilla
import { createSplitButton } from 'material';

const splitButton = createSplitButton({
  text: 'Watch later',
  icon: watchIcon,
  trailingLabel: 'More watch options',
  items: [
    { id: 'queue', text: 'Add to queue' },
    { id: 'playlist', text: 'Save to playlist' },
  ],
});
splitButton.on('click', () => watchLater());
document.body.append(splitButton.element);
Web Components
<m-split-button trailing-label="More watch options">
  Watch later
  <m-menu-item value="queue">Add to queue</m-menu-item>
  <m-menu-item value="playlist">Save to playlist</m-menu-item>
</m-split-button>

<script type="module">
  const splitButton = document.querySelector('m-split-button');
  splitButton.setAttribute('icon', watchIcon);
  splitButton.addEventListener('click', () => watchLater());
</script>
React
import { SplitButton, MenuItem } from 'material/react';
import { watchLater, watchIcon } from './app';

export function Example() {
  return (
    <SplitButton onClick={() => watchLater()} icon={watchIcon} trailingLabel="More watch options">
      Watch later
      <MenuItem value="queue">Add to queue</MenuItem>
      <MenuItem value="playlist">Save to playlist</MenuItem>
    </SplitButton>
  );
}
Vue
<script setup lang="ts">
import { MSplitButton, MMenuItem } from 'material/vue';
import { watchLater, watchIcon } from './app';
</script>

<template>
  <MSplitButton @click="watchLater()" :icon="watchIcon" trailing-label="More watch options">
    Watch later
    <MMenuItem value="queue">Add to queue</MMenuItem>
    <MMenuItem value="playlist">Save to playlist</MMenuItem>
  </MSplitButton>
</template>
Svelte
<script lang="ts">
  import { SplitButton, MenuItem } from 'material/svelte';
  import { watchLater, watchIcon } from './app';
</script>

<SplitButton onclick={() => watchLater()} icon={watchIcon} trailingLabel="More watch options">
  Watch later
  <MenuItem value="queue">Add to queue</MenuItem>
  <MenuItem value="playlist">Save to playlist</MenuItem>
</SplitButton>
SolidJS
import { SplitButton, MenuItem } from 'material/solid';
import { watchLater, watchIcon } from './app';

export function Example() {
  return (
    <SplitButton onClick={() => watchLater()} icon={watchIcon} trailingLabel="More watch options">
      Watch later
      <MenuItem value="queue">Add to queue</MenuItem>
      <MenuItem value="playlist">Save to playlist</MenuItem>
    </SplitButton>
  );
}

A chosen item emits select: the factory's payload has the item, the web component's detail its value, the item's id.

Examples

Variant and size

variant is filled, tonal, outlined or elevated, shared by both halves, and size runs from xs to xl like the button's. Opening the menu changes a state layer and the shape, never the color.

Vanilla
import { createSplitButton } from 'material';

const splitButton = createSplitButton({
  text: 'Save',
  variant: 'tonal',
  size: 'm',
  items: [
    { id: 'save-as', text: 'Save as…' },
    { id: 'save-copy', text: 'Save a copy' },
  ],
});
document.body.append(splitButton.element);
Web Components
<m-split-button variant="tonal" size="m">
  Save
  <m-menu-item value="save-as">Save as…</m-menu-item>
  <m-menu-item value="save-copy">Save a copy</m-menu-item>
</m-split-button>
React
import { SplitButton, MenuItem } from 'material/react';

export function Example() {
  return (
    <SplitButton variant="tonal" size="m">
      Save
      <MenuItem value="save-as">Save as…</MenuItem>
      <MenuItem value="save-copy">Save a copy</MenuItem>
    </SplitButton>
  );
}
Vue
<script setup lang="ts">
import { MSplitButton, MMenuItem } from 'material/vue';
</script>

<template>
  <MSplitButton variant="tonal" size="m">
    Save
    <MMenuItem value="save-as">Save as…</MMenuItem>
    <MMenuItem value="save-copy">Save a copy</MMenuItem>
  </MSplitButton>
</template>
Svelte
<script lang="ts">
  import { SplitButton, MenuItem } from 'material/svelte';
</script>

<SplitButton variant="tonal" size="m">
  Save
  <MenuItem value="save-as">Save as…</MenuItem>
  <MenuItem value="save-copy">Save a copy</MenuItem>
</SplitButton>
SolidJS
import { SplitButton, MenuItem } from 'material/solid';

export function Example() {
  return (
    <SplitButton variant="tonal" size="m">
      Save
      <MenuItem value="save-as">Save as…</MenuItem>
      <MenuItem value="save-copy">Save a copy</MenuItem>
    </SplitButton>
  );
}

setText() and setIcon() change the leading button. Without items, the factory only reports that the trailing button was activated, with expand, collapse and change, and the app opens whatever it likes. layer: 'top' shows the menu in the browser's top layer.

API

Options

text

Label of the leading button

Typestring
Defaultundefined
icon

Icon of the leading button, as an HTML string

Typestring
Defaultundefined
variant

Visual style, shared by both halves

Type'filled' | 'tonal' | 'outlined' | 'elevated'
Default'filled'
size

Size of both halves

Type'xs' | 's' | 'm' | 'l' | 'xl'
Default's'
disabled

Whether both halves are disabled

Typeboolean
Defaultfalse
trailingLabel

Accessible name of the trailing button

Typestring
Default'More options'
ariaLabel

Accessible name of the leading button, when its label is not enough

Typestring
Defaultundefined
groupLabel

Accessible name of the pair

Typestring
Defaultundefined
items

Menu items for the trailing button to open

TypeMenuContent[]
Defaultundefined
layer

Renders the menu beside the trailing button and shows it in the top layer

Type'top'
Defaultundefined
onClick

What the leading button does

Type(event: SplitButtonEvent) => void
Defaultundefined
onSelect

Called with the chosen item

Type(event: SplitButtonEvent) => void
Defaultundefined
on

Handlers for any of the events

Type{ [event]: handler }
Defaultundefined
class

Additional CSS classes

Typestring
Defaultundefined
prefix

Prefix for CSS class names

Typestring
Default'mtrl'

Methods

setText(text) / getText()

The leading button's label

Parameterstext: string
ReturnsSplitButtonComponent / string
setIcon(icon)

The leading button's icon

Parametersicon: string
ReturnsSplitButtonComponent
setItems(items) / getItems()

Replaces or reads the choices the trailing button opens

Parametersitems: MenuContent[]
ReturnsSplitButtonComponent / MenuContent[]
expand() / collapse()

Opens or closes what the trailing button opens

Parametersnone
ReturnsSplitButtonComponent
isExpanded()

Whether it is open

Parametersnone
Returnsboolean
enable() / disable()

Both halves together

Parametersnone
ReturnsSplitButtonComponent
isDisabled()

Whether the pair is disabled

Parametersnone
Returnsboolean
on(event, handler) / off(event, handler)

Adds or removes a listener

Parametersevent: string, handler: Function
ReturnsSplitButtonComponent
destroy()

Takes it off the page and releases the menu

Parametersnone
Returnsvoid
element

The group holding both halves

TypeHTMLElement
leadingElement

The leading button

TypeHTMLButtonElement
trailingElement

The trailing button

TypeHTMLButtonElement

Events

click

The leading button was activated

Payload{ splitButton, expanded, originalEvent }
expand / collapse

The trailing button opened or closed its choices

Payload{ splitButton, expanded, originalEvent }
change

Either of the two, with the new state

Payload{ splitButton, expanded, originalEvent }
select

A menu item was chosen

Payload{ splitButton, expanded, originalEvent, item }

The web component's select carries { value }; its click is the leading button's.

Styling

Colors come from the button. Filled and tonal halves stay flat on hover, as in a connected button group, so the pair reads as one control; an elevated split button keeps its elevation.

.mtrl-split-button { }
.mtrl-split-button--filled, .mtrl-split-button--xl, .mtrl-split-button--expanded { }
.mtrl-split-button__leading, .mtrl-split-button__trailing, .mtrl-split-button__chevron { }

.toolbar .mtrl-split-button {
  --mtrl-split-button-inner-shape: 8px;          /* where the halves meet */
  --mtrl-split-button-inner-shape-active: 12px;  /* the same, hovered or pressed */
}

Measurements

From the M3 split button tokens, in dp.

Size Height Leading padding Trailing padding Chevron Inner corner Inner corner, active
xs 32 12 / 10 13 22 4 8
s 40 16 / 12 13 22 4 12
m 56 24 / 24 15 26 8 12
l 96 48 / 48 29 38 12 20
xl 136 64 / 64 43 50 16 20

The halves are 2dp apart, the outer corners are a full pill, and the leading button is at least 48dp wide. The resting inner corner departs from the tokens at m, l and xl (4, 8 and 12dp), which read as square beside a full pill; set --mtrl-split-button-inner-shape to go back to them. While the menu is closed, the chevron sits 1 to 6dp off center, so it looks centered between two differently shaped ends; open, it centers and turns 180 degrees.