Split button

A primary action with a menu of related ones beside it, such as Save next to Save as and Save all.

  • vig-split-button
Import
import { SplitButton } from '@vigdx/ui/split-button';

Basic

Give the primary action a label and the related ones as items , the same typed entries as vig-menu ( command , disabled , danger , links and 'separator' ). primaryClick reports the primary action, selected a menu item.

Last action: none

Variants, sizes and states

variant and size style both parts; a projected vigButtonIcon leads the primary action. loading shows a spinner on the primary action and blocks both buttons, since the menu holds variations of the running action; disabled turns off both. Without an enabled item there is no menu button.

When to use it

Use a split button when one action is clearly the default and a few variations of it are rarer. When no action is the default, use a menu behind a single button; when the actions are unrelated, use separate buttons or a toolbar.

Styling hooks

Internal elements carry a stable data-part and the component's data-scope; both are public API, so removing one is a breaking change. Select a part by both, e.g. [data-scope="split-button"][data-part="root"] { … }: the pair stays within this component when kit components nest, and also reaches parts in overlay panels, which render outside the host. State is exposed through aria-* and, where listed, a data-state; literal values are checked by the API gate, values computed from the component's state follow its documented types. Other data-* attributes listed below (such as data-opening while an overlay animates) are API too. See Customizing.

Scope: [data-scope="split-button"]

SplitButton styling hooks
Part Element data-state
root The vig-split-button host. —
primary The vig-button of the primary action; style its [data-scope="button"][data-part="control"] . —
trigger The menu button ( aria-haspopup="menu" ); the open menu is a [data-scope="menu"] panel. —

Accessibility

  • Two buttons, two tab stops. The arrow button follows the WAI-ARIA APG menu button pattern: aria-haspopup="menu", aria-expanded and, while open, aria-controls, also in the server-rendered HTML. Enter, Space or ArrowDown open the menu on the first item, ArrowUp on the last; Escape closes it and returns focus.
  • The arrow button is named after the action, “More options for Save”, from labels.menuAriaLabel ({0} is the label), translated by the locale of provideVigdxUi.
  • While loading both buttons are aria-disabled rather than disabled, so focus stays where it is; the primary one is also aria-busy. While items holds no enabled item the menu button is left out instead of announcing a menu that cannot open.
  • The two parts are divided by a line of at least 3:1 against both (the text color on filled variants, the control border color on secondary), which forced-colors mode keeps. The focused part is drawn above the other so its focus ring shows in full, and the open menu button shows in the system Highlight color in forced-colors mode.

API

SplitButton

vig-split-button component

A primary action with a menu of related ones: a vig-button attached to a menu button that opens a vig-menu of typed items. The menu button follows the APG menu button pattern and is named after the action ("More options for Save"). Without an enabled item there is no menu button, and while loading it is unavailable too: its actions are variations of the one running.

Example :
<vig-split-button label="Save" [items]="saveOptions" (primaryClick)="save()" />
SplitButton props
Name Type Default Description
disabledbooleanfalse

Disables the primary action and the menu button.

itemsreadonly MenuEntry[][]

Entries of the menu: items and 'separator's. While none is an enabled item, the menu button is left out.

label required string—

Text of the primary action; also names the menu button.

labelsPartial<SplitButtonLabels>—

Texts (i18n): the menu button's name.

loadingbooleanfalse

Shows a spinner on the primary action and blocks it and the menu button, whose actions are variations of the one running. Both stay focusable (aria-disabled), so focus is not lost.

sizeSplitButtonSize'md'

Height and text size of both buttons.

type"button" | "submit" | "reset"'button'

type of the primary button, e.g. submit inside a form.

variantVariant'primary'

Tone of both buttons, from the shared variants.

Are you sure?