Tag

A compact label element for categorizing or labelling items.

Anatomy

<script>
  import { Tag } from "@saas-ui/svelte/components/tag";
</script>

<Tag>Label</Tag>

<!-- With close button -->
<Tag closable onClose={() => console.log("closed")}>
  Closable
</Tag>

Examples

As Button Accessibility

Wrap tag in a button element for clickable tags.

Avatar Accessibility

Use the startAvatar prop to add an avatar.

Basic Accessibility

Basic tag with default styling.

Closable Accessibility

Use the closable prop to add a close button.

Colours Accessibility

Use the colour prop to change the colour theme.

Overflow Accessibility

Use the maxWidth prop to truncate long content.

Sizes Accessibility

Use the size prop to change the size of the tag.

Variants Accessibility

Use the variant prop to change the visual style.

Props

Prop Type Default Description
variant subtle | solid | outline | surface surface The visual style of the tag.
size sm | md | lg | xl md The size of the tag.
colour gray | red | orange | yellow | green | teal | blue | cyan | purple | pink | rose - The colour theme of the tag.
closable boolean false Whether the tag is closable.
maxWidth text - Maximum width of the tag. Content exceeding this width will be truncated.
class text - CSS class to apply to the component.