UI Components

Tab

A tab of a tab list: an optional icon, the title, an optional badge, and a close button or a busy spinner. Its owner puts it in an element with the tablist role and moves focus between tabs; only the selected tab is in the tab order. A click, Enter or Space activates it; Delete, a middle click or its close button closes it when it is closable. While its title is cut, a tooltip below the tab shows the whole title on hover and on keyboard focus; a tab whose title fits shows none. Escape on a focused tab whose tooltip is shown only hides the tooltip, so in a dialog the first Escape leaves the dialog open.

Examples

Loading…

States

Loading…

API

Selector nol-tab

Import from @noldova/ui.components.angular

Inputs

NameTypeDefaultDescription
labelstring Required

The title, which is also the start of the accessible name.

iconstring | undefinedundefined

The glyph before the title; none when not bound.

selectedbooleanfalse

Whether the tab is the selected one, which is highlighted and in the tab order; false when not bound.

previewbooleanfalse

Whether the tab is a preview, which the next preview replaces; it shows in italics and assistive technology describes it as a preview. False when not bound.

workingbooleanfalse

Whether the tab's content is busy, which shows a spinner where the close button is, or before the title with TabComponent.leadingSpinner, and marks the tab busy; false when not bound.

waitingbooleanfalse

Whether the tab waits for the person, for example for an approval, which shows a raised hand in the spinner's place and at its size, and adds "waiting for your answer" to the end of the accessible name. It wins over TabComponent.working: the hand shows instead of the spinner and the tab is not marked busy. As while working, the close button takes the hand's place on hover and focus, and a tab that can't close keeps the hand. False when not bound.

closablebooleantrue

Whether the person can close the tab, which shows its close button; true when not bound.

badgestring | nullnull

What the badge means, which the accessible name includes after the title and any status, marker and underline, or null for no badge; null when not bound.

badgeCountnumber | nullnull

The count the badge shows, or null for a dot; shown only with a TabComponent.badge. Null when not bound.

imagestring | nullnull

The address of a small image before the title, such as a site's icon, 0.875rem square with 0.1875rem corners and never stretched, in place of TabComponent.icon; null when not bound. It shows once it has loaded; TabComponent.imageGlyph stands in its place before then, after it fails, and in forced colors.

imageGlyphstring | nullnull

The glyph in the image's place, such as public, while there is no image, while it loads, after it fails to load, and in forced colors, 0.875rem in the icon color; null when not bound, which shows public for an image and nothing without one.

statusTabStatus | nullnull

A status glyph in the image's place, colored by its tone, whose description the accessible name includes after the title; null when not bound.

leadingSpinnerbooleanfalse

Whether a working tab shows its spinner before the title, 0.75rem with a 1.5px stroke, in place of its image, status or icon, and keeps its close button at the end, as it is when not working; false when not bound, which keeps the spinner at the end. The waiting hand still wins.

markerTabMarker | nullnull

A glyph before everything else, in the accent color, with its own tooltip, whose label the accessible name includes after the status's description; null when not bound.

underlinestring | nullnull

What the accent underline means, such as "A teammate is using this page": set, the tab draws a 2px accent line inside its bottom edge, in the highlight color under forced colors, and the accessible name includes it after the marker's label and before the badge; null when not bound.

editingbooleanfalse

Whether the title is being edited in place: set, the label becomes the kit's text field, named "Tab title", on the label's own box, so its text starts where the label's text started and the tab, its icon, badge and close button keep their size and place. The field starts with the current title, focused and selected; a title changed meanwhile never overwrites what is typed, and the field's keys and clicks never activate or close the tab. The owner sets it back to false when TabComponent.labelKept or TabComponent.labelCancelled emits, which restores the label and, when the field had the focus, gives it back to the tab. False when not bound.

Outputs

NameTypeDescription
activatevoid

Emits when the person activates the tab; the owner selects it.

closevoid

Emits when the person closes a closable tab; the owner removes it.

labelKeptstring

Emits the field's trimmed text, possibly empty, when the person presses Enter or the field loses the focus while editing; the owner decides what the text means and leaves the mode. Emits at most once per editing session, and not for an Enter that ends a composition.

labelCancelledvoid

Emits when the person presses Escape while editing; the owner leaves the mode and keeps the title. Emits at most once per editing session, and never after TabComponent.labelKept.

Accessibility

KeyAction
TabMoves the focus to the selected tab, the tab list's one Tab stop, and then past the tab list.
Arrow RightMoves the focus to the next tab, from the last to the first. The tab list's owner handles it, as this example's does: a tab leaves moving between tabs to its owner.
Arrow LeftMoves the focus to the previous tab, from the first to the last, through the same owner.
HomeMoves the focus to the first tab, through the same owner.
EndMoves the focus to the last tab, through the same owner.
EnterActivates the focused tab, which its owner selects.
SpaceActivates the focused tab, as Enter does.
DeleteCloses the focused tab, unless it is not closable.
EscapeHides the tooltip of a focused tab whose title is cut, and does nothing more, so a dialog around it stays open.

Each tab has the tab role, inside an element its owner gives the tablist role and a name; it is marked selected or not, and only the selected tab is in the Tab order.

Its accessible name is its whole title, then what its status, its marker, its underline and its badge say, and waiting for your answer while it waits, each after a comma; a preview tab is described as Preview.

A working tab is busy unless it waits for the person; its spinner, icon and glyphs are hidden from assistive technology.

Its close button is named Close and the title, and is out of the Tab order; Delete closes the focused tab instead.

While its title is cut, a tooltip below the tab shows the whole title on hover and on keyboard focus.

Specification

Loading…