Skip to content

Tag

Draft In review Published Needs work Blocked
Design Frontend Accessibility Docs

A small status chip: a colored label with optional icons, removable, and able to host a Count.

<script>
import Tag from "@invisible-ui/svelte/Tag.svelte";
</script>
PropTypeDefaultDescription
statusTagStatus"neutral"Status/tone: neutral | info | success | warning | danger | selected.
variant"soft" | "solid""soft"Tinted background or solid fill.
size"sm" | "md""md"Chip size.
removablebooleanfalseShow a remove button.
removeLabelstring | undefinedundefinedAccessible label for the remove button.
onRemove(() => void) | undefinedundefinedCalled when the remove button is pressed.
iconSnippet | undefinedundefinedDecorative leading icon.
trailingSnippet | undefinedundefinedTrailing content, e.g. a Count.

The children are the label; the icon snippet holds a leading icon and the trailing snippet a trailing one.

  • Every status and variant puts its label at 4.5:1 or more. The solid warning tag paints --ds-components-general-feedback-warning-label-background-default under the dark --ds-components-general-feedback-warning-solid-foreground-default (4.71:1 in both themes), because the warning colour itself gives that text 3.8:1 only.
<Tag status="success" variant="solid">Published</Tag>
<Tag status="info" removable onRemove={() => {}}>Filter</Tag>
<Tag status="danger">
{#snippet icon()}<Icon><!-- … --></Icon>{/snippet}
Blocked
</Tag>

Elements uses the same light-DOM regions and reports removal without deleting itself, so the application remains the source of truth:

<ds-tag status="success" removable remove-label="Remove status">Published</ds-tag>
<script type="module">
document.querySelector("ds-tag").addEventListener("remove", removeStatus);
</script>

In React, icon and trailing take markup, and onRemove reports the press without removing the tag:

<Tag status="success" removable removeLabel="Remove status" onRemove={removeStatus}>
Published
</Tag>

Themeable via --ds-tag-*.