Skip to content
Slotted

Tag

A one-line label for a category or a value that can also be removed, pressed, followed or selected.

WholesaleFragilePriority shipping

Installation

The packages are a 0.x beta on npm, and their public API changes between beta releases without deprecation. One line installs the binding and the default theme.

bash
pnpm add @slotted/react @slotted/theme @slotted/themes

Tag or badge

A tag names a category, a filter or a value, such as the labels on an order. A badge states a status or a count and is never interactive; a tag can be removed (Tag), run a command (TagButton), navigate (TagLink) or hold a selection (TagToggle). A run of static tags written as role="list" announces its length and takes no arrow-key navigation.

Tone and variant

tone picks the semantic color: accent, secondary, info, success, warning or danger. variant picks how the tone is painted: solid fills the tag, soft tints it, outline draws the edge alone and dashed draws that edge in dashes. The default is secondary and soft. Pair the color with words, because color alone is not a signal.

AccentSecondaryInfoSuccessWarningDanger
AccentSecondaryInfoSuccessWarningDanger
AccentSecondaryInfoSuccessWarningDanger
AccentSecondaryInfoSuccessWarningDanger

Sizes and shapes

size takes the control scale: sm, md and lg. A tag shrinks and grows with the controls it sits beside. shape is pill, a fully rounded chip, or square, a rectangle with the small corner radius.

SmallMediumLarge
SmallMediumLarge

Beside a title

A tag is taller than a line of text at the same size, so a title that carries one grows its row. inline draws the tag inside the line: the line keeps its height and the text under it keeps its distance. Two items of a list, one with a tag and one without, stand at the same height.

Glyphs

A glyph goes before or after the label: the start and end props in React, and an element carrying slTagStart or slTagEnd inside slTagBody in Angular. The part sizes and centers the glyph.

Due FridayContract priceVerified address

Removing a tag

In React a tag is removable when it receives onRemove, which also renders the remove control. In Angular a tag is removable when it carries removable, and a button with slTagRemove draws the control; the remove output emits the request. Removing is a request, not a change: the application drops the value from its own list. The control is named from messages.remove and the tag’s label, so it reads “Remove Fragile”. Backspace and Delete on a focused control inside the tag ask for the same removal. Remove tags here with the mouse, then with the keyboard.

WholesaleFragilePriority shippingGift wrap

Confirming a removal

The request carries reason, remove for the control and keyboard for Backspace or Delete, and cancel(). Calling cancel() refuses the removal and the group leaves focus where it is, so the application can ask first. In this example the tag stays until the person confirms, and the message states how the removal was requested.

ProductionStaging

Disabled and refused removal

disabled refuses every interaction the tag offers, its removal included, and sets data-disabled on the tag. A disabled TagButton is natively disabled. A disabled TagLink loses its href and announces aria-disabled, because an anchor without a destination is not a link. removeDisabled refuses only the removal and leaves the rest of the tag operable.

ArchivedRequiredCarrier portal

TagButton runs a command on the button that is the tag’s body. TagLink navigates on a real anchor, so middle click and “open in new tab” keep working. In Angular the element carrying slTagBody decides which one the tag is: a span does nothing, a button runs a command and an a navigates. Here the carriers link to their own pages and the last tag reveals the rest of the list.

Selection

TagToggle holds a selection and exposes it as aria-pressed. A selected tag fills and draws a check before the label, so the state is not color alone. defaultSelected sets the starting state of an uncontrolled toggle, which keeps its own selection. A disabled toggle takes no press.

Controlled filters

Pass selected to own the selection. A press calls onSelectedChange in React and emits selectedChange in Angular, and the tag moves only when the new value is passed back. In Angular the request exposes the new value as $event.value. A toggle can also be removable: here each filter leaves the bar with its control or with Backspace.

1 of 4 filters applied.

Groups

TagGroup is a toolbar by default: one tab stop, and the arrow keys move between the controls inside it, each tag’s body and then its remove control. orientation="vertical" changes the keys to up and down and writes aria-orientation. loop={false} in React and [loop]="false" in Angular stops the arrow keys at the ends of the run instead of wrapping.

Defaults

A defaults provider sets tone, variant, size and shape once for every tag under it: TagDefaultsProvider in React, provideTagDefaults in Angular. A tag that sets a prop of its own keeps it.

InboundCross-dockCold chain

Accessibility

tag

  • The WAI-ARIA Authoring Practices define no tag or chip pattern. The group follows the Toolbar pattern, a chip that acts and the remove control follow the Button pattern, a chip that navigates follows the Link pattern, and a chip that holds a selection uses aria-pressed from WAI-ARIA 1.2.
  • The chip box is never the interactive element. A button cannot contain a button and an anchor cannot contain either, so a chip that both acts and removes puts its two controls side by side: the body is the primary target and the remove control is its sibling.
  • The remove control’s name is composed, not repeated: aria-labelledby joins a hidden word to the tag’s own label, so it announces “Remove Design” rather than “Remove”. Text referenced by aria-labelledby counts even when the element holding it is hidden.
  • Backspace and Delete on any control inside a removable tag ask for the same removal the X does, and the request says which of the two it was.
  • The focus ring is drawn on the control, never on the chip: a chip can hold two controls, and a ring around the whole box could not say which one has focus. The ring is inset, so it does not cover the remove control beside the body or touch the next tag in a wrapped run.
  • The remove control is as tall as the chip and as wide as its glyph plus a step of air on each side, floored at the WCAG 2.2 2.5.8 minimum of 24 CSS pixels, which carries it past that minimum in both axes at every size and every density. The chip’s own height is floored at that minimum for the same reason.
  • A tag is one line. A value too long for its container is clipped with an ellipsis rather than reflowed, and the clipping is visual only: text-overflow shortens nothing, so the whole value stays in the DOM, stays in the accessibility tree, and a page search still finds it.
  • The label is a bidi isolate whose direction comes from its own first strong character, so an Arabic value inside an English page reads right to left and is clipped at its own end.
  • Under forced colors every tone ground becomes one system color, so tag draws its edge in currentColor there, and a selected chip takes the system’s own Highlight pair — its whole signal is a ground the system has replaced.
  • A static tag carries no role of its own. What a value means comes from where it sits, and a role invented here would be wrong more often than right.
  • A group of static tags is written role="list", which announces its length and turns the arrow keys off — a list is a structure rather than a widget.

tagButton

  • The WAI-ARIA Authoring Practices define no tag or chip pattern. The group follows the Toolbar pattern, a chip that acts and the remove control follow the Button pattern, a chip that navigates follows the Link pattern, and a chip that holds a selection uses aria-pressed from WAI-ARIA 1.2.
  • The chip box is never the interactive element. A button cannot contain a button and an anchor cannot contain either, so a chip that both acts and removes puts its two controls side by side: the body is the primary target and the remove control is its sibling.
  • The remove control’s name is composed, not repeated: aria-labelledby joins a hidden word to the tag’s own label, so it announces “Remove Design” rather than “Remove”. Text referenced by aria-labelledby counts even when the element holding it is hidden.
  • Backspace and Delete on any control inside a removable tag ask for the same removal the X does, and the request says which of the two it was.
  • The focus ring is drawn on the control, never on the chip: a chip can hold two controls, and a ring around the whole box could not say which one has focus. The ring is inset, so it does not cover the remove control beside the body or touch the next tag in a wrapped run.
  • The remove control is as tall as the chip and as wide as its glyph plus a step of air on each side, floored at the WCAG 2.2 2.5.8 minimum of 24 CSS pixels, which carries it past that minimum in both axes at every size and every density. The chip’s own height is floored at that minimum for the same reason.
  • A tag is one line. A value too long for its container is clipped with an ellipsis rather than reflowed, and the clipping is visual only: text-overflow shortens nothing, so the whole value stays in the DOM, stays in the accessibility tree, and a page search still finds it.
  • The label is a bidi isolate whose direction comes from its own first strong character, so an Arabic value inside an English page reads right to left and is clipped at its own end.
  • Under forced colors every tone ground becomes one system color, so tag draws its edge in currentColor there, and a selected chip takes the system’s own Highlight pair — its whole signal is a ground the system has replaced.
  • The command is a real button, so Enter and Space both activate it and the platform supplies the rest.
  • A disabled TagButton is natively disabled. Reach for aria-disabled through rootProps only when the chip has to stay in the tab sequence to explain itself.

tagLink

  • The WAI-ARIA Authoring Practices define no tag or chip pattern. The group follows the Toolbar pattern, a chip that acts and the remove control follow the Button pattern, a chip that navigates follows the Link pattern, and a chip that holds a selection uses aria-pressed from WAI-ARIA 1.2.
  • The chip box is never the interactive element. A button cannot contain a button and an anchor cannot contain either, so a chip that both acts and removes puts its two controls side by side: the body is the primary target and the remove control is its sibling.
  • The remove control’s name is composed, not repeated: aria-labelledby joins a hidden word to the tag’s own label, so it announces “Remove Design” rather than “Remove”. Text referenced by aria-labelledby counts even when the element holding it is hidden.
  • Backspace and Delete on any control inside a removable tag ask for the same removal the X does, and the request says which of the two it was.
  • The focus ring is drawn on the control, never on the chip: a chip can hold two controls, and a ring around the whole box could not say which one has focus. The ring is inset, so it does not cover the remove control beside the body or touch the next tag in a wrapped run.
  • The remove control is as tall as the chip and as wide as its glyph plus a step of air on each side, floored at the WCAG 2.2 2.5.8 minimum of 24 CSS pixels, which carries it past that minimum in both axes at every size and every density. The chip’s own height is floored at that minimum for the same reason.
  • A tag is one line. A value too long for its container is clipped with an ellipsis rather than reflowed, and the clipping is visual only: text-overflow shortens nothing, so the whole value stays in the DOM, stays in the accessibility tree, and a page search still finds it.
  • The label is a bidi isolate whose direction comes from its own first strong character, so an Arabic value inside an English page reads right to left and is clipped at its own end.
  • Under forced colors every tone ground becomes one system color, so tag draws its edge in currentColor there, and a selected chip takes the system’s own Highlight pair — its whole signal is a ground the system has replaced.
  • The destination is a real anchor, so middle click, the context menu, download and “open in new tab” all keep working.
  • A chip that navigates to another origin says so in its own words or in a visually hidden sentence. The external marker belongs to the link family, on a link.

tagToggle

  • The WAI-ARIA Authoring Practices define no tag or chip pattern. The group follows the Toolbar pattern, a chip that acts and the remove control follow the Button pattern, a chip that navigates follows the Link pattern, and a chip that holds a selection uses aria-pressed from WAI-ARIA 1.2.
  • The chip box is never the interactive element. A button cannot contain a button and an anchor cannot contain either, so a chip that both acts and removes puts its two controls side by side: the body is the primary target and the remove control is its sibling.
  • The remove control’s name is composed, not repeated: aria-labelledby joins a hidden word to the tag’s own label, so it announces “Remove Design” rather than “Remove”. Text referenced by aria-labelledby counts even when the element holding it is hidden.
  • Backspace and Delete on any control inside a removable tag ask for the same removal the X does, and the request says which of the two it was.
  • The focus ring is drawn on the control, never on the chip: a chip can hold two controls, and a ring around the whole box could not say which one has focus. The ring is inset, so it does not cover the remove control beside the body or touch the next tag in a wrapped run.
  • The remove control is as tall as the chip and as wide as its glyph plus a step of air on each side, floored at the WCAG 2.2 2.5.8 minimum of 24 CSS pixels, which carries it past that minimum in both axes at every size and every density. The chip’s own height is floored at that minimum for the same reason.
  • A tag is one line. A value too long for its container is clipped with an ellipsis rather than reflowed, and the clipping is visual only: text-overflow shortens nothing, so the whole value stays in the DOM, stays in the accessibility tree, and a page search still finds it.
  • The label is a bidi isolate whose direction comes from its own first strong character, so an Arabic value inside an English page reads right to left and is clipped at its own end.
  • Under forced colors every tone ground becomes one system color, so tag draws its edge in currentColor there, and a selected chip takes the system’s own Highlight pair — its whole signal is a ground the system has replaced.
  • A selected tag announces aria-pressed, not aria-selected. aria-selected is only valid inside a listbox, a grid or a tree, and an option may not contain the remove control that tag puts beside the label.
  • The label never changes with the state, which is the APG’s rule for a toggle: “Open” stays “Open” and the state is announced beside it.
  • Selection is not color alone. The chip fills, and a check grows into the label beside the words — WCAG 2.2 1.4.1.

API

tag

Props

tone'accent' | 'secondary' | 'info' | 'success' | 'warning' | 'danger'Default secondary
Which of the six semantic colors the tag speaks in
variant'solid' | 'soft' | 'outline' | 'dashed'Default soft
How that color is painted: filled, tinted, an edge alone, or that edge in dashes. A selected tag fills whatever its variant
size'sm' | 'md' | 'lg'Default md
Type, glyph and gap come from the control scale, so a tag shrinks with density beside the controls it sits with
shape'pill' | 'square'Default pill
A rounded chip, or a rectangle with the small corner radius
inlinebooleanDefault false
No taller than the line of text around it, for a title or a sentence: the line keeps its height and what is under it its distance. The tag takes its own size where the line has the room and one line of the text where it does not; its words are at most nine tenths of the text around it.
startReactNode
A glyph or an avatar before the words, wrapped in the start part, which sizes and centers it
endReactNode
A glyph after the words, wrapped in the end part
disabledbooleanDefault false
Refuses every interaction the tag offers, including its removal
onRemove(request: TagRemoveRequest) => void
Asks to be removed. The remove control is rendered only when this is present. request.reason is remove for the control and keyboard for Backspace or Delete; request.cancel() refuses it, and the group then leaves focus where it is
messagesPartial<TagMessages>
Overrides for the strings of the language in force, by key: remove is the word the remove control announces before the tag’s own label, so it reads “Remove Design”
removeDisabledbooleanDefault false
Refuses the removal while the rest of the tag stays operable
orientation'horizontal' | 'vertical'Default horizontal
On TagGroupWhich way the run reads. vertical also writes aria-orientation
loopbooleanDefault true
On TagGroupWhether the arrow keys wrap past the ends of the run
rolestringDefault toolbar
On TagGrouptoolbar makes the run one tab stop with arrow navigation inside it. Writing list turns that off and gives every chip role="listitem"
render(props) => ReactNode
On every memberRenders the member’s own element into another one — an li for a tag in a list, a router’s link component for a destination
rootPropsComponentProps<'span'>
On TagButton, TagLink, TagToggleReaches the chip box, which an interactive member’s own props do not land on
refRef<HTMLElement>
On every memberReaches the element the member is: the chip box for Tag, the control for the other three
TagDefaultsProvider{ tone, variant, size, shape }
On a subtreeSets the defaults once for every tag under it; an explicit prop still wins

tagButton

Props

tone'accent' | 'secondary' | 'info' | 'success' | 'warning' | 'danger'Default secondary
Which of the six semantic colors the tag speaks in
variant'solid' | 'soft' | 'outline' | 'dashed'Default soft
How that color is painted: filled, tinted, an edge alone, or that edge in dashes. A selected tag fills whatever its variant
size'sm' | 'md' | 'lg'Default md
Type, glyph and gap come from the control scale, so a tag shrinks with density beside the controls it sits with
shape'pill' | 'square'Default pill
A rounded chip, or a rectangle with the small corner radius
startReactNode
A glyph or an avatar before the words, wrapped in the start part, which sizes and centers it
endReactNode
A glyph after the words, wrapped in the end part
disabledbooleanDefault false
Refuses every interaction the tag offers, including its removal
onRemove(request: TagRemoveRequest) => void
Asks to be removed. The remove control is rendered only when this is present. request.reason is remove for the control and keyboard for Backspace or Delete; request.cancel() refuses it, and the group then leaves focus where it is
messagesPartial<TagMessages>
Overrides for the strings of the language in force, by key: remove is the word the remove control announces before the tag’s own label, so it reads “Remove Design”
removeDisabledbooleanDefault false
Refuses the removal while the rest of the tag stays operable
onClick(event) => void
The command. It lands on the button the chip’s body is, so type, form and every native button prop reach the element that owns them

Props

tone'accent' | 'secondary' | 'info' | 'success' | 'warning' | 'danger'Default secondary
Which of the six semantic colors the tag speaks in
variant'solid' | 'soft' | 'outline' | 'dashed'Default soft
How that color is painted: filled, tinted, an edge alone, or that edge in dashes. A selected tag fills whatever its variant
size'sm' | 'md' | 'lg'Default md
Type, glyph and gap come from the control scale, so a tag shrinks with density beside the controls it sits with
shape'pill' | 'square'Default pill
A rounded chip, or a rectangle with the small corner radius
startReactNode
A glyph or an avatar before the words, wrapped in the start part, which sizes and centers it
endReactNode
A glyph after the words, wrapped in the end part
disabledbooleanDefault false
Refuses every interaction the tag offers, including its removal
onRemove(request: TagRemoveRequest) => void
Asks to be removed. The remove control is rendered only when this is present. request.reason is remove for the control and keyboard for Backspace or Delete; request.cancel() refuses it, and the group then leaves focus where it is
messagesPartial<TagMessages>
Overrides for the strings of the language in force, by key: remove is the word the remove control announces before the tag’s own label, so it reads “Remove Design”
removeDisabledbooleanDefault false
Refuses the removal while the rest of the tag stays operable
hrefstring
The destination. A disabled TagLink loses it and announces aria-disabled, because an anchor without a destination is not a link

tagToggle

Props

tone'accent' | 'secondary' | 'info' | 'success' | 'warning' | 'danger'Default secondary
Which of the six semantic colors the tag speaks in
variant'solid' | 'soft' | 'outline' | 'dashed'Default soft
How that color is painted: filled, tinted, an edge alone, or that edge in dashes. A selected tag fills whatever its variant
size'sm' | 'md' | 'lg'Default md
Type, glyph and gap come from the control scale, so a tag shrinks with density beside the controls it sits with
shape'pill' | 'square'Default pill
A rounded chip, or a rectangle with the small corner radius
startReactNode
A glyph or an avatar before the words, wrapped in the start part, which sizes and centers it
endReactNode
A glyph after the words, wrapped in the end part
disabledbooleanDefault false
Refuses every interaction the tag offers, including its removal
onRemove(request: TagRemoveRequest) => void
Asks to be removed. The remove control is rendered only when this is present. request.reason is remove for the control and keyboard for Backspace or Delete; request.cancel() refuses it, and the group then leaves focus where it is
messagesPartial<TagMessages>
Overrides for the strings of the language in force, by key: remove is the word the remove control announces before the tag’s own label, so it reads “Remove Design”
removeDisabledbooleanDefault false
Refuses the removal while the rest of the tag stays operable
selectedbooleanDefault false
The selection the consumer owns. Passing it puts the tag in controlled mode for good
defaultSelectedboolean
The selection an uncontrolled tag starts from, read once. A later change to it is not silently adopted
onSelectedChange(selected, request) => void
Asks for the opposite selection. request.reason is pointer or keyboard, and request.cancel() refuses it

Theming

Each token is a CSS custom property: set it in a theme, or on any element to retune every tag inside it.

Tag tokens

TokenDefault
--slotted-tag-border-colorvar(--slotted-tone-secondary-border)
--slotted-tag-border-widthvar(--slotted-border-width-thin, 1px)
--slotted-tag-font-familyvar(--slotted-control-font-family, sans-serif)
--slotted-tag-font-weightvar(--slotted-font-weight-medium, 500)
--slotted-tag-group-gapvar(--slotted-space-2, 0.25rem)
--slotted-tag-inset-blockvar(--slotted-space-2, 0.25rem)
--slotted-tag-inset-inlinevar(--slotted-space-4, 0.5rem)
--slotted-tag-state-layer-active14%
--slotted-tag-state-layer-hover8%

Theme tokens it reads

TokenDefault
--slotted-border-width-thin1px
--slotted-control-font-familyvar(--slotted-font-family-sans)
--slotted-control-font-size-lgcomfortable 14px · compact 13px · dense 12px
--slotted-control-font-size-mdcomfortable 13px · compact 12px · dense 12px
--slotted-control-font-size-smcomfortable 12px · compact 12px · dense 12px
--slotted-control-icon-size-mdcomfortable 16px · compact 14px · dense 13px
--slotted-control-icon-size-smcomfortable 14px · compact 13px · dense 12px
--slotted-control-inner-sizevar(--_own-size)
--slotted-control-inner-size-mdcomfortable 24px · compact 20px · dense 18px
--slotted-control-inner-size-smcomfortable 22px · compact 18px · dense 16px
--slotted-control-transition-durationvar(--slotted-duration-short)
--slotted-control-transition-easingvar(--slotted-easing-standard)
--slotted-disabled-backgroundSet per scheme by the theme
--slotted-disabled-borderSet per scheme by the theme
--slotted-disabled-foregroundSet per scheme by the theme
--slotted-duration-short120ms
--slotted-easing-standardcubic-bezier(0.2, 0, 0, 1)
--slotted-focus-ring-colorSet per scheme by the theme
--slotted-focus-ring-offsetvar(--slotted-border-width-thick)
--slotted-focus-ring-widthvar(--slotted-border-width-thick)
--slotted-font-weight-medium500
--slotted-line-height-xs1.4
--slotted-radius-full9999px
--slotted-radius-sm4px
--slotted-space-10.125rem
--slotted-space-20.25rem
--slotted-space-30.375rem
--slotted-space-40.5rem
--slotted-space-50.75rem
--slotted-target-comfortable44px
--slotted-target-min24px
--slotted-text-box-edgecap alphabetic
--slotted-tone-accent-borderSet per scheme by the theme
--slotted-tone-accent-on-solidSet per scheme by the theme
--slotted-tone-accent-solidSet per scheme by the theme
--slotted-tone-accent-solid-activeSet per scheme by the theme
--slotted-tone-accent-solid-hoverSet per scheme by the theme
--slotted-tone-accent-subtle-activeSet per scheme by the theme
--slotted-tone-accent-subtle-hoverSet per scheme by the theme
--slotted-tone-accent-surfaceSet per scheme by the theme
--slotted-tone-accent-textSet per scheme by the theme
--slotted-tone-danger-borderSet per scheme by the theme
--slotted-tone-danger-on-solidSet per scheme by the theme
--slotted-tone-danger-solidSet per scheme by the theme
--slotted-tone-danger-solid-activeSet per scheme by the theme
--slotted-tone-danger-solid-hoverSet per scheme by the theme
--slotted-tone-danger-subtle-activeSet per scheme by the theme
--slotted-tone-danger-subtle-hoverSet per scheme by the theme
--slotted-tone-danger-surfaceSet per scheme by the theme
--slotted-tone-danger-textSet per scheme by the theme
--slotted-tone-info-borderSet per scheme by the theme
--slotted-tone-info-on-solidSet per scheme by the theme
--slotted-tone-info-solidSet per scheme by the theme
--slotted-tone-info-solid-activeSet per scheme by the theme
--slotted-tone-info-solid-hoverSet per scheme by the theme
--slotted-tone-info-subtle-activeSet per scheme by the theme
--slotted-tone-info-subtle-hoverSet per scheme by the theme
--slotted-tone-info-surfaceSet per scheme by the theme
--slotted-tone-info-textSet per scheme by the theme
--slotted-tone-secondary-borderSet per scheme by the theme
--slotted-tone-secondary-on-solidSet per scheme by the theme
--slotted-tone-secondary-solid-activeSet per scheme by the theme
--slotted-tone-secondary-solid-hoverSet per scheme by the theme
--slotted-tone-secondary-subtle-activeSet per scheme by the theme
--slotted-tone-secondary-subtle-hoverSet per scheme by the theme
--slotted-tone-secondary-surfaceSet per scheme by the theme
--slotted-tone-secondary-textSet per scheme by the theme
--slotted-tone-success-borderSet per scheme by the theme
--slotted-tone-success-on-solidSet per scheme by the theme
--slotted-tone-success-solidSet per scheme by the theme
--slotted-tone-success-solid-activeSet per scheme by the theme
--slotted-tone-success-solid-hoverSet per scheme by the theme
--slotted-tone-success-subtle-activeSet per scheme by the theme
--slotted-tone-success-subtle-hoverSet per scheme by the theme
--slotted-tone-success-surfaceSet per scheme by the theme
--slotted-tone-success-textSet per scheme by the theme
--slotted-tone-warning-borderSet per scheme by the theme
--slotted-tone-warning-on-solidSet per scheme by the theme
--slotted-tone-warning-solidSet per scheme by the theme
--slotted-tone-warning-solid-activeSet per scheme by the theme
--slotted-tone-warning-solid-hoverSet per scheme by the theme
--slotted-tone-warning-subtle-activeSet per scheme by the theme
--slotted-tone-warning-subtle-hoverSet per scheme by the theme
--slotted-tone-warning-surfaceSet per scheme by the theme
--slotted-tone-warning-textSet per scheme by the theme