Split button
vig-split-button
import { SplitButton } from '@vigdx/ui/split-button';Basic
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.
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"]
| Part | Element | data-state |
|---|---|---|
root | vig-split-button host. | — |
primary | vig-button of the primary action; style its [data-scope="button"][data-part="control"] . | — |
trigger | 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-expandedand, 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 ofprovideVigdxUi. - While
loadingboth buttons arearia-disabledrather than disabled, so focus stays where it is; the primary one is alsoaria-busy. Whileitemsholds 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-buttonA 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.
<vig-split-button label="Save" [items]="saveOptions" (primaryClick)="save()" />| Name | Type | Default | Description |
|---|---|---|---|
disabled | boolean | false | Disables the primary action and the menu button. |
items | readonly MenuEntry[] | [] | Entries of the menu: items and |
label | string | — | Text of the primary action; also names the menu button. |
labels | Partial<SplitButtonLabels> | — | Texts (i18n): the menu button's name. |
loading | boolean | false | 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
( |
size | SplitButtonSize | 'md' | Height and text size of both buttons. |
type | "button" | "submit" | "reset" | 'button' |
|
variant | Variant | 'primary' | Tone of both buttons, from the shared variants. |
| Name | Payload | Description |
|---|---|---|
primaryClick | MouseEvent | Emitted when the primary action is clicked (not while |
selected | MenuItem | Emitted when a menu item is activated (its |