Ant Design Svelte

Tag

Labels, statuses, controlled filters, groups, closing, animation and rearrangement.

When to use

Tag denotes a category, property, or state of an object. CheckableTag is suitable for a toggle filter, CheckableTagGroup combines single or multiple selections. A label does not replace a regular action button unless it has appropriate semantics.

Tags, links and closure

children contains a signature, icon is a decorative snippet. color accepts a preset, status, or CSS color. variant selects filled/outlined/solid. href creates a real link; disabled disables transition and closing.

Problem Opportunity Example
Show link or closable label href, closable, onClose Label actions
Color the category color, variant Palette
Store list of tags application status Adding and deleting
Switch filters CheckableTag, CheckableTagGroup Choice
Show process or result status color Statuses

onClose receives MouseEvent. preventDefault overrides built-in hiding. When the array stores the application, undo this hiding, update the data yourself and after the tick return focus to the available field or adjacent action.

closable accepts boolean or close control settings with ARIA attributes and closeIcon. closeLabel takes precedence over the close-config and locale signature. Clicking close should not additionally activate the transition or onclick of the entire label.

Tags as filters

CheckableTag is a native button with aria-pressed. checked is entirely owner controlled: onChange reports a new value to pass back. This is different from a do-it-yourself switch with internal binding.

For CheckableTagGroup, defaultValue sets the initial value, value — controlled selection. Without multiple, the result is either null; with multiple - an array. A string and a number with the same text are considered different values. Use unique options.value and an accessible group name.

Do not mix deleting a category and removing a filter: closable for a regular Tag removes the tag, checked for a CheckableTag changes the selection. Every action should have a clear signature.

Animation, order and design

Animation uses Svelte transition and reduced motion. Rearrangement - native drag/drop for desktop and reorder buttons. This is the logic of examples; A separate Motion API or dnd-kit is not included in the library.

ConfigProvider.tag specifies variant, closure, classes and styles; local props take precedence. The nested tag replaces the entire parent record. CheckableTag inherits class/style, and checked remains with the owner.

Semantic root/icon/content/close design a regular Tag; content exists if icon is present. The group supports root/item, a separate CheckableTag supports regular class/style. styles are specified by CSS strings. Tag design tokens control the appearance of tags; the color should be complemented by the status text.

Tag, CheckableTag and CheckableTagGroup inherit ConfigProvider.prefixCls with the -tag suffix, defaulting to ant-tag. The group adds -checkable-group. A non-empty local prefixCls takes precedence over a global one; an empty string returns the provider's fallback. A group's local prefix does not rename its CheckableTag: they separately inherit the common prefix. Common prefix switches without resetting checked and selecting a group. The names of CSS variables and semantic slots are preserved.

Examples

Regular tag Buttons Lockable Protected Unavailable link
Closing the protected label is cancelled.

Closure and links

Normal label, link, veto and disabled.

filled

magenta red volcano orange gold lime green cyan blue geekblue purple Your color

outlined

magenta red volcano orange gold lime green cyan blue geekblue purple Your color

solid

magenta red volcano orange gold lime green cyan blue geekblue purple Your color

Colors and variants

Preset palette and custom color.

Svelte TypeScript
Add a new label.

Adding and deleting

Array of labels, check for duplicates and return focus.

Selected: no
Books
Музыка

Filter tags

Single button, single and multiple groups.

Verified With badge

Badges

SVG Snippet, filter icon and your own closeIcon.

filled

success processing warning error default

outlined

success processing warning error default

solid

success processing warning error default

Statuses

Five statuses in three variants.

Label 1 Label 2 Label 3

Animation

Svelte scale and reduced motion.

  1. Svelte
  2. TypeScript
  3. Documents
Svelte, TypeScript, Документы

Rearranging labels

Native drag/drop and reorder buttons.

styles object Function styles

Semantic DOM

Label and group design object and function.

From context Local priority
Local topic Text default solid

Component tokens

Three label tokens in the local provider.

Preview Tag
blue purple cyan green magenta pink red orange yellow volcano geekblue lime gold
Ready At work Requires verification Error

Project tags

Svelte TypeScript Documentation

Task filtering

Add a label or select a task status. Tasks shown: 4.

Tag editor from review

Project labels, required label and table filtering.

API

Use Tag.CheckableTag and Tag.CheckableTagGroup. Both are also available as named imports. Full types are published in @woodger/antd.

Example themes
ThemeExample or limitation
BasicClosing, veto, available name and link.
Colorful TagPalette and custom CSS color in three variants.
Add & Remove DynamicallyManaged array and return focus.
CheckableSingle label, single and multiple groups.
AnimateMotion adaptation: Svelte scale with reduced motion.
IconSnippet of the icon for Tag and CheckableTag, its own closeIcon.
Status TagFive statuses for filled/outlined/solid.
Draggable TagAdaptation of dnd-kit: native drag and rearrangement buttons.
Custom semantic dom stylingDesign of Tag and CheckableTagGroup.

Tag

PropertyDescriptionTypeDefault
prefixClsFull local CSS prefix Tag. The empty string and undefined inherit ConfigProvider.prefixCls; default ant-tag.stringConfigProvider + -tag
colorPreset, status or CSS color.TagColordefault
variantBackground, outline or solid color.filled | outlined | solidfilled
closableClosing and aria attributes close control.boolean | TagCloseConfig | nullfalse
closeIconAbbreviation for closing; true enables the default icon.TagCloseIcon—
closeLabelThe name of the close button, takes precedence over closable aria-label.stringlocale.closeText
onClosepreventDefault overrides built-in hiding.(event: MouseEvent) => void—
iconDecorative icon before content.Snippet—
hrefA non-empty address creates a native anchor.string—
disabledBlocks actions; removes the href from the link.booleancontext / false
classNamesAn object or function of the slots classes.TagSemantic—
stylesCSS string object or function slots.TagSemantic—

CheckableTag

PropertyDescriptionTypeDefault
prefixClsFull local CSS prefix of CheckableTag. The empty string and undefined inherit ConfigProvider.prefixCls; default ant-tag.stringConfigProvider + -tag
checkedThe owner stores the value; There is no internal uncontrolled mode.booleanfalse
onChangeRequest to switch after pressing or Space.(checked: boolean) => void—
disabledDisables the native button.booleancontext / false
iconDecorative badge.Snippet—

CheckableTagGroup

PropertyDescriptionTypeDefault
prefixClsFull local base CSS group prefix with -checkable-group suffix. The empty string and undefined inherit ConfigProvider.prefixCls; default ant-tag. CheckableTag variants separately inherit the common prefix.stringConfigProvider + -tag
optionsUnique values; 1 and line 1 are different.readonly (Value | CheckableTagOption<Value>)[][]
multipleSingle value or array.booleanfalse
valueControlled via onChange; bind:value is not used.Value | null | Value[]local state
defaultValueInitial uncontrolled value.Value | null | Value[]—
onChangeThe type of result depends on multiple.(value) => void—
disabledDisables item switching.booleancontext / false
stylesRoot and item; object or function.CheckableTagGroupSemantic<Value>—

Tag.icon and group content support Snippet. styles are specified by CSS strings. The closure passes the native MouseEvent; close config disabled and afterClose are not used as in the reference.

Semantic DOM

Tag uses span or a, close uses native button. CheckableTag - button with aria-pressed; Group groups together buttons. content slot exists if icon is present. CheckableTag accepts regular class/style.

Tag
SlotPurpose
rootLabel or link.
iconIcon.
contentContent with icon.
closeClose button.
CheckableTagGroup
SlotPurpose
rootGroup container.
itemChild CheckableTag.

Registration tokens

theme.components.Tag applies defaultBg, defaultColor and solidTextColor. The latter sets the text default solid; colored solid use colorTextLightSolid. Semantic and regular inline styles retain priority.

TokenPurpose
defaultBgBackground of a regular label.
defaultColorNormal label color.
solidTextColorText color default solid.
Common tokens of the current topic
TokenMeaning
colorPrimary#2f54eb
colorTextrgba(0,0,0,0.88)
colorTextDisabledrgba(0,0,0,0.25)
colorBorder#d9d9d9
fontSizeSM12
lineHeightSM1.6666666666666667
borderRadiusSM4
paddingXS8

FAQ

How not to delete the label after pressing close?

Call preventDefault in onClose. If the array is storing the application, update it yourself and regain focus after tick.

How to store filters?

CheckableTag gets checked/onChange. Group uses value or initial defaultValue; multiple defines an array of results.

Where is animation and rearrangement implemented?

In the site examples: Svelte transition, native drag and buttons. React Motion/dnd-kit has not been added to the library.

What settings are inherited?

ConfigProvider.tag specifies variant, closure and decoration. A nested record replaces the parent one; CheckableTag only inherits class/style.