Toolbar
vig-toolbar [vigToolbarStart] [vigToolbarCenter] [vigToolbarEnd]
import { Toolbar, ToolbarStart, ToolbarCenter, ToolbarEnd } from '@vigdx/ui/toolbar';Basic
labels.ariaLabel . Buttons, toggle buttons, button groups, split buttons and menus are items; a vig-divider separates them. vigToolbarEnd moves an item to the end.
Start, center and end
vigToolbarStart (or no marker), vigToolbarCenter and vigToolbarEnd place items in a region; the regions are logical, so the end is on the left in right-to-left pages. The toolbar draws no frame of its own: add one with classes on the host.
More actions
vig-menu behind a “More actions” button. Actions without a visible result report it in a status message outside the toolbar.
Vertical
orientation="vertical" stacks the items, for a tool palette beside a canvas; ArrowUp and ArrowDown move between them and the end region sits at the bottom. Use horizontal dividers in it.
When the items do not fit
A horizontal toolbar wraps its items onto more lines; nothing is ever clipped or hidden, and the arrow keys follow the same order on every line. The toolbar does not move items into a menu by itself on purpose: a select, a text field or a radio group cannot become a menu item, so an automatic overflow would only work for plain buttons and would duplicate every action in two places.
For a single line on narrow screens, decide which actions are secondary and put them in a trailing vig-menu, as in the More actions example. To hide an item only below a width, hide it with CSS (class="max-sm:hidden") and list the same action in the menu; the toolbar skips hidden items, so the tab stop never lands on one.
Toolbar or button group
A button group only attaches a few buttons visually; each stays its own tab stop. Use a toolbar when there are several controls (three or more) that act on one piece of content, so keyboard users reach them with one Tab and move on with the next. A toolbar can hold button groups.
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="toolbar"][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="toolbar"]
| Part | Element | data-state |
|---|---|---|
root | vig-toolbar host ( role="toolbar" ); also carries data-orientation ( horizontal , vertical ). | — |
start | [vigToolbarStart] and unmarked content. | — |
center | [vigToolbarCenter] ), hidden while empty. | — |
end | [vigToolbarEnd] ). | — |
Accessibility
- Follows the WAI-ARIA APG toolbar pattern:
role="toolbar"with an accessible name (labels.ariaLabel, “Actions” by default; anaria-labelledbyyou add on the host wins) andaria-orientation. - One tab stop (a roving
tabindex): Tab enters on the first item, or the one used last. ArrowRight and ArrowLeft move to the next and previous item, mirrored in right-to-left pages; a vertical toolbar uses ArrowDown and ArrowUp instead. Movement wraps at the ends, and Home and End jump to the first and last item. - Natively disabled controls and hidden ones (by an attribute or by CSS, such as a breakpoint class) are skipped. Controls marked
aria-disabledstay items, so a disabled action can still be discovered; that is how to disable one in a toolbar. Tab comes back to the item used last, also after the toolbar was hidden. - Every item stays reachable. A text field keeps Home, End and the arrow keys for its caret, and hands the arrow keys over once the caret is at the edge they point past. A native radio group, such as
vig-select-button, is one item: the arrow keys move its selection, and past its first or last option they move on; Home and End jump out of it. - Controls that need every arrow key and cannot hand them over (native selects, number and date fields, listboxes, tabs) are not items: they keep their own tab stop, reached with Tab. Content of a dialog or popover declared inside the toolbar is not part of it either.
- A control that handles a key itself keeps it. In a vertical toolbar the toolbar takes ArrowUp and ArrowDown from a collapsed menu button, split button or select, which open with Enter or Space.
- The toolbar only writes the
tabindexof its items, and puts back the one it replaced when a control stops being an item or the toolbar goes away. - The server renders every control in the tab order; the browser narrows it to one tab stop once the page has hydrated.
API
Toolbar
vig-toolbarA row (or column) of controls that act on something else, such as an editor or a table, following the APG toolbar pattern: one tab stop, arrow keys between the controls (mirrored in RTL), Home and End to the first and last. A text field hands the arrow keys over once the caret is at its edge, a radio group at its first and last radio; controls that need every arrow key (selects, number and date fields, listboxes, tabs) keep their own tab stop instead of joining the roving one.
Put kit or native controls straight inside; vigToolbarStart,
vigToolbarCenter and vigToolbarEnd place them in a region.
<vig-toolbar [labels]="{ ariaLabel: 'Text formatting' }">
<vig-toggle-button onLabel="Bold" [(value)]="bold" />
<vig-toggle-button onLabel="Italic" [(value)]="italic" />
<vig-divider orientation="vertical" />
<vig-button vigToolbarEnd label="Share" variant="secondary" />
</vig-toolbar>| Name | Type | Default | Description |
|---|---|---|---|
labels | Partial<ToolbarLabels> | — | Texts (i18n): the toolbar's accessible name; locale default "Actions". |
orientation | ToolbarOrientation | 'horizontal' |
|
Templates and directives
| Selector | Export | Description |
|---|---|---|
[vigToolbarStart] | ToolbarStart | Projects content into the toolbar's start region (where unmarked content goes too). |
[vigToolbarCenter] | ToolbarCenter | Projects content into the toolbar's center region. |
[vigToolbarEnd] | ToolbarEnd | Projects content into the toolbar's end region (right in LTR, left in RTL). |