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
Closure and links
Normal label, link, veto and disabled.
<script lang="ts">
import { Checkbox, Tag } from '@woodger/antd';
let protect = $state(true);
let message = $state(("Closing the protected label is cancelled."));
</script>
<style>
.example {
display: grid;
gap: 16px;
}
.tags {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 8px;
}
</style>
<div class="example">
<div class="tags">
<Tag>{("Regular tag")}</Tag>
<Tag href={("/ant-design/components/button")}>{("Buttons")}</Tag>
<Tag
closable
closeLabel={("Remove regular label")}
>{("Lockable")}</Tag>
<Tag closable={{ 'aria-label': "Remove protected label" }} onClose={event => {
if (protect) event.preventDefault();
message = protect ? ("Closing cancelled.") : ("The label is closed.");
}}>{("Protected")}</Tag>
<Tag href={("/ant-design/components/button")} disabled>
{("Unavailable link")}
</Tag>
</div>
<Checkbox bind:checked={protect}>{("Protect tag from closing")}</Checkbox>
<output aria-label={("Closing Tag")}>{message}</output>
</div>
filled
outlined
solid
Colors and variants
Preset palette and custom color.
<script lang="ts">
import { Tag, type TagPresetColor, type TagVariant } from '@woodger/antd';
const colors = [
'magenta',
'red',
'volcano',
'orange',
'gold',
'lime',
'green',
'cyan',
'blue',
'geekblue',
'purple'
] as const satisfies readonly TagPresetColor[];
const variants = ['filled', 'outlined', 'solid'] as const satisfies readonly TagVariant[];
</script>
<style>
.variants {
display: grid;
gap: 24px;
}
.tags {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
h4 {
margin: 0 0 12px;
font: inherit;
font-weight: 600;
}
</style>
<div class="variants">
{#each variants as variant (variant)}
<div><h4>{(variant)}</h4><div class="tags">
{#each colors as color (color)}<Tag {color} {variant}>{(color)}</Tag>{/each}
<Tag color="#874d00" {variant}>{("Your color")}</Tag>
</div></div>
{/each}
</div>
Adding and deleting
Array of labels, check for duplicates and return focus.
<script lang="ts">
import { tick } from 'svelte';
import { Button, Input, Tag } from '@woodger/antd';
const inputId = $props.id();
let values = $state(['Svelte', 'TypeScript']);
let draft = $state<string | undefined>('');
let message = $state(("Add a new label."));
async function add(event: SubmitEvent) {
event.preventDefault();
const next = draft?.trim();
if (!next || values.includes(next)) {
message = next
? ("Such a mark already exists.")
: ("Enter a name.");
return;
}
values = [...values, next];
draft = '';
message = ("Added: " + String((next)) + "");
await tick();
const input = document.getElementById(inputId);
input?.focus();
}
async function remove(event: MouseEvent, value: string) {
event.preventDefault();
values = values.filter(item => item !== value);
message = ("Removed: " + String((value)) + "");
await tick();
const input = document.getElementById(inputId);
input?.focus();
}
</script>
<style>
.example {
display: grid;
gap: 16px;
}
.tags, form {
display: flex;
align-items: end;
flex-wrap: wrap;
gap: 8px;
}
.field {
display: grid;
gap: 8px;
max-width: 100%;
}
</style>
<div class="example">
<div class="tags" aria-label={("Dynamic labels")}>
{#each values as value (value)}
<Tag
closable
closeLabel={`Delete ${value}`}
onClose={event => remove(event, value)}
>{(value)}</Tag>
{/each}
</div>
<form onsubmit={add}>
<div
class="field"
><label
for={inputId}
>{("New label")}</label><Input
id={inputId}
bind:value={draft}
maxLength={40}
/></div>
<Button htmlType="submit">{("Add tag")}</Button>
</form>
<output aria-label={("Dynamic labels: result")}>{message}</output>
</div>
Filter tags
Single button, single and multiple groups.
<script lang="ts">
import { CheckableTag, CheckableTagGroup } from '@woodger/antd';
let checked = $state(false);
let single = $state<string | null>(("Books"));
let multiple = $state<string[]>(["Music"]);
const options = ["Books", "Music", "Sports"];
</script>
<style>
.examples {
display: grid;
gap: 20px;
}
.field {
display: grid;
gap: 8px;
}
</style>
<div class="examples">
<div class="field">
<CheckableTag
{checked}
onChange={next => { checked = next; }}
>{("Favorites")}</CheckableTag>
<output aria-label={("Separate filter")}>{("Selected: ")}{(checked ? "yes" : "no")}</output>
</div>
<div class="field">
<CheckableTagGroup role="group" aria-label={("One interest")} options={(options)} value={single}
onChange={(next: string | null) => { single = next; }} />
<output aria-label={("One interest: result")}>{(single
?? ("Nothing"))}</output>
</div>
<div class="field">
<CheckableTagGroup
role="group"
aria-label={("Several interests")}
options={(options)}
multiple
value={multiple}
onChange={next => { multiple = next; }}
/>
<output aria-label={("Several interests: result")}>{(multiple.join(', ')
|| ("Nothing"))}</output>
</div>
</div>
Badges
SVG Snippet, filter icon and your own closeIcon.
<script lang="ts">
import { CheckableTag, Tag } from '@woodger/antd';
let checked = $state(false);
</script>
<style>
.tags {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 8px;
}
</style>
{#snippet icon()}<svg
width="14"
height="14"
viewBox="0 0 24 24"
fill="none"
aria-hidden="true"
><path
d="m5 12 4 4L19 6"
stroke="currentColor"
stroke-width="2"
/></svg>{/snippet}
{#snippet close()}<span aria-hidden="true">×</span>{/snippet}
<div class="tags">
<Tag {icon} color="success">{("Verified")}</Tag>
<Tag {icon} closeIcon={close} closeLabel={("Remove label with icon")}>
{("With badge")}
</Tag>
<CheckableTag {icon} {checked} onChange={next => { checked = next; }}>
{("Verified")}
</CheckableTag>
</div>
filled
success processing warning error defaultoutlined
success processing warning error defaultsolid
success processing warning error defaultStatuses
Five statuses in three variants.
<script lang="ts">
import { Tag, type TagStatusColor, type TagVariant } from '@woodger/antd';
const statuses =
[
'success',
'processing',
'warning',
'error',
'default'
] as const satisfies readonly TagStatusColor[];
const variants = ['filled', 'outlined', 'solid'] as const satisfies readonly TagVariant[];
</script>
<style>
.examples {
display: grid;
gap: 20px;
}
.row {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 8px;
}
h4 {
flex-basis: 100%;
margin: 0;
font: inherit;
font-weight: 600;
}
</style>
<div class="examples">
{#each variants as variant (variant)}
<div class="row"><h4>{(variant)}</h4>
{#each statuses as color (color)}<Tag {color} {variant}>{(color)}</Tag>{/each}
</div>
{/each}
</div>
Animation
Svelte scale and reduced motion.
<script lang="ts">
import { tick } from 'svelte';
import { scale } from 'svelte/transition';
import { prefersReducedMotion } from 'svelte/motion';
import { Button, Tag } from '@woodger/antd';
const addId = $props.id();
let sequence = 3;
let values = $state([1, 2, 3]);
async function remove(event: MouseEvent, value: number) {
event.preventDefault();
values = values.filter(item => item !== value);
await tick();
const addButton = document.getElementById(addId);
addButton?.focus();
}
</script>
<style>
.example {
display: grid;
justify-items: start;
gap: 16px;
}
.tags {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
</style>
<div class="example">
<div class="tags">
{#each values as value (value)}
<span transition:scale={{ duration: prefersReducedMotion.current ? 0 : 150 }}>
<Tag
closable
closeLabel={`Remove animated mark ${value}`}
onClose={event => remove(event, value)}
>{("Label ")}{(value)}</Tag>
</span>
{/each}
</div>
<Button id={addId} onclick={() => { values = [...values, ++sequence]; }}>
{("Add with animation")}
</Button>
</div>
- Svelte
- TypeScript
- Documents
Rearranging labels
Native drag/drop and reorder buttons.
<script lang="ts">
import { Button, Tag } from '@woodger/antd';
let values = $state(['Svelte', 'TypeScript', "Documents"]);
let dragged = $state<string>();
function move(value: string, offset: number) {
const from = values.indexOf(value);
const to = from + offset;
if (to < 0 || to >= values.length) {
return;
}
const next = [...values];
next.splice(from, 1);
next.splice(to, 0, value);
values = next;
}
function drop(event: DragEvent, target: string) {
event.preventDefault();
if (!dragged || dragged === target) {
return;
}
move(dragged, values.indexOf(target) - values.indexOf(dragged));
dragged = undefined;
}
</script>
<style>
ol {
display: flex;
flex-wrap: wrap;
gap: 12px;
margin: 0;
padding: 0;
list-style: none;
}
li {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 8px;
}
output {
display: block;
margin-top: 16px;
}
</style>
<ol aria-label={("Label order")}>
{#each values as value, index (value)}
<li draggable="true" ondragstart={event => {
dragged = value;
event.dataTransfer?.setData('text/plain', value);
}} ondragover={event => { event.preventDefault(); }} ondrop={event => drop(event, value)}
ondragend={() => { dragged = undefined; }}>
<Tag>{(value)}</Tag>
<Button
size="small"
aria-label={("Move " + String((value)) + " left")}
disabled={index === 0}
onclick={() => move(value, -1)}
>←</Button>
<Button
size="small"
aria-label={("Move " + String((value)) + " right")}
disabled={index === values.length - 1}
onclick={() => move(value, 1)}
>→</Button>
</li>
{/each}
</ol>
<output aria-label={("Result of rearrangement")}>{values.join(', ')}</output>
Semantic DOM
Label and group design object and function.
<script lang="ts">
import { CheckableTagGroup, Tag } from '@woodger/antd';
</script>
<style>
.examples {
display: grid;
justify-items: start;
gap: 16px;
}
</style>
{#snippet icon()}<span aria-hidden="true">✓</span>{/snippet}
<div class="examples">
<Tag {icon} closable closeLabel={("Close checkout")} classNames={{
root: 'tag-object'
}}
styles={{
root: 'padding: 4px 12px',
icon: 'color: var(--ant-color-success)',
content: 'font-weight: 700',
close: 'margin-inline-start: 12px'
}}>{("styles object")}</Tag>
<Tag
color="purple"
variant="outlined"
classNames={() => ({ root: 'tag-function' })}
styles={({ props }) => ({ root: `font-weight: ${props.variant === 'outlined' ? 700 : 400}` })}
>{("Function styles")}</Tag>
<CheckableTagGroup role="group" aria-label={("Decorated group")} options={(["Code", "Design"])}
classNames={{ root: 'tag-group-object', item: 'tag-group-item' }}
styles={{
root: 'gap: 12px',
item: 'border-radius: 12px'
}} />
</div>
General settings
ConfigProvider.tag and local priority.
<script lang="ts">
import { ConfigProvider, Tag } from '@woodger/antd';
</script>
<style>
.tags {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
</style>
<ConfigProvider tag={{ variant: 'outlined', closable: true }}>
<div class="tags">
<Tag color="green" closeLabel={("Close general settings")}>
{("From context")}
</Tag>
<Tag
color="purple"
variant="solid"
closable={false}
>{("Local priority")}</Tag>
</div>
</ConfigProvider>
Component tokens
Three label tokens in the local provider.
<script lang="ts">
import { ConfigProvider, Tag } from '@woodger/antd';
</script>
<style>
.tags {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
</style>
<ConfigProvider theme={{
components: {
Tag: {
defaultBg: '#fff7e6', defaultColor: '#874d00', solidTextColor: '#fff7e6'
}
}
}}>
<div
class="tags"
><Tag>{("Local topic")}</Tag><Tag
variant="solid"
color="default"
>{("Text default solid")}</Tag></div>
</ConfigProvider>
Project tags
Task filtering
Problem | Status |
|---|---|
| Подготовить релиз | Ready |
| Обновить документацию | At work |
| Проверить доступность | Requires verification |
| Повторить сборку | Error |
Tag editor from review
Project labels, required label and table filtering.
TagExample.svelte<script lang="ts"> import { Button, Checkbox, CheckableTag, Input, Select, Table, Tag, type TableColumn, type TagColor, type TagStatusColor, type TagVariant } from '@woodger/antd'; import { createTagLabels, type TagLabel } from './tag-labels.model.svelte'; interface Task { key: number; name: string; status: TagStatusColor; } const model = createTagLabels(); const presets: TagColor[] = [ 'blue', 'purple', 'cyan', 'green', 'magenta', 'pink', 'red', 'orange', 'yellow', 'volcano', 'geekblue', 'lime', 'gold' ]; const statuses: { value: TagStatusColor; label: string }[] = [ { value: 'success', label: "Ready" }, { value: 'processing', label: "At work" }, { value: 'warning', label: "Requires verification" }, { value: 'error', label: "Error" } ]; const tasks: Task[] = [ { key: 1, name: "Prepare release", status: 'success' }, { key: 2, name: "Update documentation", status: 'processing' }, { key: 3, name: "Check availability", status: 'warning' }, { key: 4, name: "Repeat assembly", status: 'error' } ]; const columns: TableColumn<Task>[] = [ { key: 'name', title: "Problem", dataIndex: 'name' }, { key: 'status', title: "Status", render: taskStatus } ]; let color = $state<TagColor>('blue'); let variant = $state<TagVariant>('filled'); let close = $state(true); let icon = $state(false); let disabled = $state(false); let protectPreview = $state(false); let previewVersion = $state(0); let draft = $state<string | undefined>(''); let selected = $state<TagStatusColor[]>([]); let message = $state(("Add a label or select a task status.")); let visible = $derived(tasks.filter(task => !selected.length || selected.includes(task.status))); function focusInput() { const input = document.getElementById('tag-example-label'); input?.focus({ preventScroll: true }); } function add(event: SubmitEvent) { event.preventDefault(); const result = model.add(draft ?? ''); message = result === 'added' ? ("Tag added.") : result === 'duplicate' ? ("Such a mark already exists.") : ("Enter the label name."); if (result === 'added') draft = ''; focusInput(); } function remove(event: MouseEvent, label: TagLabel) { if (!model.remove(label.key)) { event.preventDefault(); message = ("Label " + String((label.text)) + " is required."); return; } message = ("Label " + String((label.text)) + " has been removed."); if (model.labels.length === 1) focusInput(); } function toggle(value: TagStatusColor, checked: boolean) { selected = checked ? [...selected, value] : selected.filter(item => item !== value); } function reset() { model.reset(); selected = []; draft = ''; color = 'blue'; variant = 'filled'; close = true; icon = false; disabled = false; protectPreview = false; previewVersion++; message = ("Start marks restored."); } </script> <style> .controls, .tags { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; } .controls { gap: 12px; } .fields { align-items: flex-end; } .field { width: 180px; max-width: 100%; } .wide { width: 260px; max-width: 100%; } .wide label { display: block; margin-bottom: 8px; } .preview { margin-block: 24px; padding: 20px; border: 1px solid var(--ant-color-border-secondary); border-radius: var(--ant-border-radius-lg); } .tags, .table { margin-block: 16px; } .controls :global(.ant-btn) { max-width: 100%; height: auto; min-height: var(--ant-control-height); white-space: normal; } .controls :global(.ant-btn-sm) { min-height: var(--ant-control-height-sm); } .controls :global(.ant-btn-lg) { min-height: var(--ant-control-height-lg); } output { display: block; margin-top: 16px; color: var(--ant-color-text-secondary); } </style> {#snippet previewIcon()}<svg width="16" height="16" viewBox="0 0 24 24"><path d="m5 12 4 4L19 6" fill="none" stroke="currentColor" stroke-width="2" /></svg>{/snippet} {#snippet taskStatus(task: Task)}{@const status = statuses.find( item => item.value === task.status )}<Tag color={task.status}>{(status?.label)}</Tag>{/snippet} <div class="controls"><div class="field"><Select aria-label={("Color Tag")} bind:value={color} options={([...presets, 'default', 'success', 'processing', 'error', 'warning'] .map(value => ({ value: value as TagColor, label: value })))} /></div><div class="field"><Select aria-label={("Option Tag")} bind:value={variant} options={(['filled', 'outlined', 'solid'] .map(value => ({ value: value as TagVariant, label: value })))} /></div><Checkbox bind:checked={close} >{("Closing Tag")}</Checkbox><Checkbox bind:checked={icon} >{("Icon Tag")}</Checkbox><Checkbox bind:checked={disabled} >{("Disable Tag")}</Checkbox><Checkbox bind:checked={protectPreview} >{("Cancel closing Tag")}</Checkbox></div> <div class="preview"><div class="tags">{#key previewVersion}<Tag {color} {variant} {disabled} icon={icon ? previewIcon : undefined} closeIcon={close} closeLabel={("Close preview mark")} onClose={event => { if (protectPreview) event.preventDefault(); message = protectPreview ? ("Closing cancelled.") : ("The preview mark is closed."); }} >{("Preview Tag")}</Tag>{/key}<Button onclick={() => { previewVersion++; }} >{("Restore Tag")}</Button></div><div class="tags" aria-label={("Preset Colors Tag")} >{#each presets as value}<Tag color={value} {variant} >{(value)}</Tag>{/each}</div><div class="tags" aria-label={("Status colors Tag")} >{#each statuses as item}<Tag color={item.value} {variant} >{(item.label)}</Tag>{/each}</div></div> <h3>{("Project tags")}</h3> <form class="controls fields" aria-label={("Adding marks")} onsubmit={add} ><div class="wide" ><label for="tag-example-label" >{("New project label")}</label><Input id="tag-example-label" bind:value={draft} /></div><Button type="primary" htmlType="submit" >{("Add tag")}</Button><Button onclick={reset} >{("Reset example Tag")}</Button></form> <div class="tags" role="group" aria-label={("Project tags")} >{#each model.labels as label (label.key)}<Tag color={label.protected ? 'blue' : 'default'} closeIcon closeLabel={`Remove label ${label.text}`} onClose={event => remove(event, label)} >{(label.text)}</Tag>{/each}</div> <h3>{("Task filtering")}</h3> <div class="tags" role="group" aria-label={("Filter tasks by status")} >{#each statuses as item}<CheckableTag checked={selected.includes(item.value)} onChange={checked => toggle(item.value, checked)} >{(item.label)}</CheckableTag>{/each}</div> <div class="table"><Table dataSource={(visible)} columns={(columns)} caption={("Tasks with status marks")} pagination={(false)} /></div> <output aria-label={("Example result Tag")}>{message}{(" Tasks shown: ")}{(visible.length)}.</output>tag-labels.model.svelte.tsexport interface TagLabel { key: number; text: string; protected: boolean; } export type TagAddResult = 'added' | 'empty' | 'duplicate'; export function createTagLabels() { let sequence = 0; const defaults = () => ['Svelte', 'TypeScript', "Documentation"].map( (text, index) => ({ key: sequence++, text, protected: index === 0 }) ); let labels = $state<TagLabel[]>(defaults()); return { get labels(): readonly TagLabel[] { return labels; }, add(value: string): TagAddResult { const text = value.trim(); if (!text) { return 'empty'; } if ( labels.some(label => label.text.toLocaleLowerCase('ru') === text.toLocaleLowerCase('ru')) ) { return 'duplicate'; } labels = [...labels, { key: sequence++, text, protected: false }]; return 'added'; }, remove(key: number): boolean { const label = labels.find(item => item.key === key); if (!label || label.protected) { return false; } labels = labels.filter(item => item.key !== key); return true; }, reset() { labels = defaults(); } }; }
API
Use Tag.CheckableTag and Tag.CheckableTagGroup. Both are also available as named imports. Full types are published in @woodger/antd.
| Theme | Example or limitation |
|---|---|
| Basic | Closing, veto, available name and link. |
| Colorful Tag | Palette and custom CSS color in three variants. |
| Add & Remove Dynamically | Managed array and return focus. |
| Checkable | Single label, single and multiple groups. |
| Animate | Motion adaptation: Svelte scale with reduced motion. |
| Icon | Snippet of the icon for Tag and CheckableTag, its own closeIcon. |
| Status Tag | Five statuses for filled/outlined/solid. |
| Draggable Tag | Adaptation of dnd-kit: native drag and rearrangement buttons. |
| Custom semantic dom styling | Design of Tag and CheckableTagGroup. |
Tag
| Property | Description | Type | Default |
|---|---|---|---|
prefixCls | Full local CSS prefix Tag. The empty string and undefined inherit ConfigProvider.prefixCls; default ant-tag. | string | ConfigProvider + -tag |
color | Preset, status or CSS color. | TagColor | default |
variant | Background, outline or solid color. | filled | outlined | solid | filled |
closable | Closing and aria attributes close control. | boolean | TagCloseConfig | null | false |
closeIcon | Abbreviation for closing; true enables the default icon. | TagCloseIcon | — |
closeLabel | The name of the close button, takes precedence over closable aria-label. | string | locale.closeText |
onClose | preventDefault overrides built-in hiding. | (event: MouseEvent) => void | — |
icon | Decorative icon before content. | Snippet | — |
href | A non-empty address creates a native anchor. | string | — |
disabled | Blocks actions; removes the href from the link. | boolean | context / false |
classNames | An object or function of the slots classes. | TagSemantic | — |
styles | CSS string object or function slots. | TagSemantic | — |
CheckableTag
| Property | Description | Type | Default |
|---|---|---|---|
prefixCls | Full local CSS prefix of CheckableTag. The empty string and undefined inherit ConfigProvider.prefixCls; default ant-tag. | string | ConfigProvider + -tag |
checked | The owner stores the value; There is no internal uncontrolled mode. | boolean | false |
onChange | Request to switch after pressing or Space. | (checked: boolean) => void | — |
disabled | Disables the native button. | boolean | context / false |
icon | Decorative badge. | Snippet | — |
CheckableTagGroup
| Property | Description | Type | Default |
|---|---|---|---|
prefixCls | Full 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. | string | ConfigProvider + -tag |
options | Unique values; 1 and line 1 are different. | readonly (Value | CheckableTagOption<Value>)[] | [] |
multiple | Single value or array. | boolean | false |
value | Controlled via onChange; bind:value is not used. | Value | null | Value[] | local state |
defaultValue | Initial uncontrolled value. | Value | null | Value[] | — |
onChange | The type of result depends on multiple. | (value) => void | — |
disabled | Disables item switching. | boolean | context / false |
styles | Root 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.
| Slot | Purpose |
|---|---|
root | Label or link. |
icon | Icon. |
content | Content with icon. |
close | Close button. |
| Slot | Purpose |
|---|---|
root | Group container. |
item | Child 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.
| Token | Purpose |
|---|---|
defaultBg | Background of a regular label. |
defaultColor | Normal label color. |
solidTextColor | Text color default solid. |
| Token | Meaning |
|---|---|
colorPrimary | #2f54eb |
colorText | rgba(0,0,0,0.88) |
colorTextDisabled | rgba(0,0,0,0.25) |
colorBorder | #d9d9d9 |
fontSizeSM | 12 |
lineHeightSM | 1.6666666666666667 |
borderRadiusSM | 4 |
paddingXS | 8 |
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.