Tag
tags, status, filtros gerenciados, grupos, fechamento, animação e permutação.
Quando usar
tag denota a categoria, propriedade ou estado do objeto. CheckableTag Adequado para filtros comutáveis, CheckableTagGroup Integra uma ou múltipla escolha. O rótulo não substitui o botão de ação normal se não tiver a semântica correspondente.
Etiquetas, links e fechamentos
children Contém uma assinatura, icon — trecho decorativo. color Aceita predefinição, status ou cor CSS. variant Seleciona filled/outlined/solid. href Cria um link real; disabled Desativa a transição e o fechamento.
| Tarefa | Oportunidade | Exemplo |
|---|---|---|
| Mostrar link ou tag fechada | href, closable, onClose |
Ação da tag |
| Designar cor | color, variant |
Paleta |
| Armazene os rótulos | Status do aplicativo | Adicione e remova |
| Switch Filters | CheckableTag, CheckableTagGroup |
Selecione |
| show Processo ou resultado | Status color |
Status |
onClose Obtém MouseEvent. preventDefault Cancele o esconderijo integrado. Quando a matriz estiver armazenando o aplicativo, desfaça este hide, atualize os dados você mesmo e retorne o foco para um campo disponível ou uma ação adjacente.
closable Aceita boolean as configurações de controle próximo com atributos ARIA e closeIcon. closeLabel tem precedência sobre a configuração de close-config e localidade da assinatura. Pressionar o fechamento não deve ativar ainda mais a transição ou onclick de toda a marca.
Etiquetas como filtros
CheckableTag — Botão nativo com aria-pressed. checked Totalmente controlado pelo proprietário: onChange Relata um novo valor que precisa ser repassado. Isso é diferente do self switch com a ligação interna.
CheckableTagGroup defaultValue Define o valor inicial, value — seleção controlada. Sem multiple o resultado é o valor null; com multiple - array. Uma string e um número com o mesmo texto são considerados valores diferentes. Use o nome exclusivo options.value e o grupo disponível.
Não misture a remoção da categoria e remova o filtro: closable A tag normal remove o rótulo, checked para CheckableTag muda a escolha. Cada ação deve ter uma assinatura clara.
Animação, pedido e design
Animação usa Svelte transição e movimento reduzido. Rearranjo — Drag nativo/drop para desktop e botão de reordenação. Esta é a lógica dos exemplos; Um API separado ou um kit DND não está incluído na biblioteca.
ConfigProvider.tag set variant, fechamento, classes e estilos; Os propriedades locais têm prioridade. A tag aninhada substitui totalmente o registro pai. CheckableTag Herda class/style e checked permanece com o proprietário.
Semântica root/icon/content/close Faça uma tag regular; content Existe quando icon está disponível. O grupo suporta root/item, separado CheckableTag — o usual class/style. styles é definido por CSS strings. Tokens de design Tag Gerenciar o design da etiqueta; A cor deve ser complementada com o texto do status.
tag, CheckableTag e CheckableTagGroup herdar ConfigProvider.prefixCls com sufixo -tag, padrão ant-tag. O grupo adiciona -checkable-group. local não vazio prefixCls prioridade sobre o geral; Uma string vazia retorna um provedor de fallback. O grupo local de prefixos não o renomeia CheckableTag: eles herdam separadamente o prefixo comum. Prefixo geral Switchs sem reset checked e seleção de grupo. Os nomes CSS variáveis e slots semânticos são salvos.
Exemplos
Fechamento e links
Normal, link, veto e disabled.
<script lang="ts">
import { Checkbox, Tag } from '@woodger/antd';
let protect = $state(true);
let message = $state(("O fechamento da etiqueta protegida é cancelada."));
</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>{("Marca normal")}</Tag>
<Tag href={("/ant-design/components/button")}>{("Botões")}</Tag>
<Tag
closable
closeLabel={("Remova a marca normal")}
>{("Fechado")}</Tag>
<Tag closable={{ 'aria-label': "Remova a marca protegida" }} onClose={event => {
if (protect) event.preventDefault();
message = protect ? ("O fechamento foi cancelado.") : ("A etiqueta está fechada.");
}}>{("Protegido")}</Tag>
<Tag href={("/ant-design/components/button")} disabled>
{("Link indisponível")}
</Tag>
</div>
<Checkbox bind:checked={protect}>{("Proteja a etiqueta do fechamento")}</Checkbox>
<output aria-label={("Tag de fechamento")}>{message}</output>
</div>
filled
outlined
solid
cores e variantes
Paleta predefinida e cores personalizadas.
<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}>{("sua cor")}</Tag>
</div></div>
{/each}
</div>
Adicione e remova
Matriz de rótulos, verificação duplicada e retorno de foco.
<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(("Adicione um novo rótulo."));
async function add(event: SubmitEvent) {
event.preventDefault();
const next = draft?.trim();
if (!next || values.includes(next)) {
message = next
? ("Já existe essa tag.")
: ("Digite um nome.");
return;
}
values = [...values, next];
draft = '';
message = ("adicionado: " + 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 = ("Removido: " + 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={("Tags dinâmicas")}>
{#each values as value (value)}
<Tag
closable
closeLabel={`Excluir ${value}`}
onClose={event => remove(event, value)}
>{(value)}</Tag>
{/each}
</div>
<form onsubmit={add}>
<div
class="field"
><label
for={inputId}
>{("Novo rótulo")}</label><Input
id={inputId}
bind:value={draft}
maxLength={40}
/></div>
<Button htmlType="submit">{("Adicione um rótulo")}</Button>
</form>
<output aria-label={("Tags dinâmicas: resultado")}>{message}</output>
</div>
Filtros de tags
Botão separado, grupo único e múltiplo.
<script lang="ts">
import { CheckableTag, CheckableTagGroup } from '@woodger/antd';
let checked = $state(false);
let single = $state<string | null>(("Livros"));
let multiple = $state<string[]>(["Música"]);
const options = ["Livros", "Música", "Sport"];
</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; }}
>{("Favoritos")}</CheckableTag>
<output aria-label={("Filtro separado")}>{("Selecionado: ")}{(checked ? "sim" : "não")}</output>
</div>
<div class="field">
<CheckableTagGroup role="group" aria-label={("Um interesse")} options={(options)} value={single}
onChange={(next: string | null) => { single = next; }} />
<output aria-label={("Um interesse: Resultado")}>{(single
?? ("Nada"))}</output>
</div>
<div class="field">
<CheckableTagGroup
role="group"
aria-label={("interesses múltiplos")}
options={(options)}
multiple
value={multiple}
onChange={next => { multiple = next; }}
/>
<output aria-label={("Interesses múltiplos: resultado")}>{(multiple.join(', ')
|| ("Nada"))}</output>
</div>
</div>
ícones
SVG Snippet, ícone de filtro e 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">{("verificado")}</Tag>
<Tag {icon} closeIcon={close} closeLabel={("Remover etiqueta com o ícone")}>
{("com")}
</Tag>
<CheckableTag {icon} {checked} onChange={next => { checked = next; }}>
{("Verificado")}
</CheckableTag>
</div>
filled
success processing warning error defaultoutlined
success processing warning error defaultsolid
success processing warning error defaultStatus
Cinco status em três variantes.
<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>
Animação
Svelte escala e movimento reduzido.
<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={`Remover tag animada ${value}`}
onClose={event => remove(event, value)}
>{("Rótulo ")}{(value)}</Tag>
</span>
{/each}
</div>
<Button id={addId} onclick={() => { values = [...values, ++sequence]; }}>
{("Adicione com animação")}
</Button>
</div>
- Svelte
- TypeScript
- Documentos
Recálculo
Botões nativos de arrastar/drop e alterar os botões de ordem.
<script lang="ts">
import { Button, Tag } from '@woodger/antd';
let values = $state(['Svelte', 'TypeScript', "Documentos"]);
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={("Pedido de etiqueta")}>
{#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={("Mover " + String((value)) + " Esquerda")}
disabled={index === 0}
onclick={() => move(value, -1)}
>←</Button>
<Button
size="small"
aria-label={("Mover " + String((value)) + " direito")}
disabled={index === values.length - 1}
onclick={() => move(value, 1)}
>→</Button>
</li>
{/each}
</ol>
<output aria-label={("Resultado da permutação")}>{values.join(', ')}</output>
Semantic DOM
Objeto e função de rotulagem e design de grupo.
<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={("Fechar decoração")} classNames={{
root: 'tag-object'
}}
styles={{
root: 'padding: 4px 12px',
icon: 'color: var(--ant-color-success)',
content: 'font-weight: 700',
close: 'margin-inline-start: 12px'
}}>{("Estilos Objeto")}</Tag>
<Tag
color="purple"
variant="outlined"
classNames={() => ({ root: 'tag-function' })}
styles={({ props }) => ({ root: `font-weight: ${props.variant === 'outlined' ? 700 : 400}` })}
>{("Estilos de função")}</Tag>
<CheckableTagGroup role="group" aria-label={("Grupo decorado")} options={(["Código", "Design"])}
classNames={{ root: 'tag-group-object', item: 'tag-group-item' }}
styles={{
root: 'gap: 12px',
item: 'border-radius: 12px'
}} />
</div>
Configurações gerais
ConfigProvider.tag e prioridade local.
<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={("Feche as configurações gerais")}>
{("Do contexto")}
</Tag>
<Tag
color="purple"
variant="solid"
closable={false}
>{("Prioridade local")}</Tag>
</div>
</ConfigProvider>
Tokens de componentes
Três tokens de rótulo no provedor local.
<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>{("Tema local")}</Tag><Tag
variant="solid"
color="default"
>{("Texto Default Solid")}</Tag></div>
</ConfigProvider>
Tags do projeto
Filtragem de tarefas
Tarefa | Status |
|---|---|
| Подготовить релиз | Concluído |
| Обновить документацию | no trabalho |
| Проверить доступность | Requer |
| Повторить сборку | Erro |
Editor de etiquetas de
Tags do projeto, etiqueta obrigatória e filtragem da tabela.
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: "Concluído" }, { value: 'processing', label: "no trabalho" }, { value: 'warning', label: "Requer" }, { value: 'error', label: "Erro" } ]; const tasks: Task[] = [ { key: 1, name: "Prepare a liberação", status: 'success' }, { key: 2, name: "Atualizar documentação", status: 'processing' }, { key: 3, name: "Verifique a disponibilidade", status: 'warning' }, { key: 4, name: "Repetir Assembly", status: 'error' } ]; const columns: TableColumn<Task>[] = [ { key: 'name', title: "Tarefa", 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(("Adicione um rótulo ou selecione um status de tarefa.")); 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' ? ("Rótulo adicionado.") : result === 'duplicate' ? ("Já existe essa tag.") : ("Insira o nome do rótulo."); if (result === 'added') draft = ''; focusInput(); } function remove(event: MouseEvent, label: TagLabel) { if (!model.remove(label.key)) { event.preventDefault(); message = ("Rótulo " + String((label.text)) + " Obrigatório."); return; } message = ("Rótulo " + String((label.text)) + " Removido."); 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 = ("Marcas de início restauradas."); } </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={("Etiqueta de cor")} 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={("Tag de opção")} bind:value={variant} options={(['filled', 'outlined', 'solid'] .map(value => ({ value: value as TagVariant, label: value })))} /></div><Checkbox bind:checked={close} >{("Tag de fechamento")}</Checkbox><Checkbox bind:checked={icon} >{("Ícone de tag")}</Checkbox><Checkbox bind:checked={disabled} >{("Desative a tag")}</Checkbox><Checkbox bind:checked={protectPreview} >{("Cancelar tag")}</Checkbox></div> <div class="preview"><div class="tags">{#key previewVersion}<Tag {color} {variant} {disabled} icon={icon ? previewIcon : undefined} closeIcon={close} closeLabel={("Feche a marca de visualização")} onClose={event => { if (protectPreview) event.preventDefault(); message = protectPreview ? ("O fechamento foi cancelado.") : ("A etiqueta de visualização está fechada."); }} >{("Etiqueta de visualização")}</Tag>{/key}<Button onclick={() => { previewVersion++; }} >{("Restaurar tag")}</Button></div><div class="tags" aria-label={("Tag de cores predefinidas")} >{#each presets as value}<Tag color={value} {variant} >{(value)}</Tag>{/each}</div><div class="tags" aria-label={("Status Tag de cores")} >{#each statuses as item}<Tag color={item.value} {variant} >{(item.label)}</Tag>{/each}</div></div> <h3>{("Tags do projeto")}</h3> <form class="controls fields" aria-label={("Adicione marcas")} onsubmit={add} ><div class="wide" ><label for="tag-example-label" >{("Novo projeto Marca")}</label><Input id="tag-example-label" bind:value={draft} /></div><Button type="primary" htmlType="submit" >{("Adicione um rótulo")}</Button><Button onclick={reset} >{("Redefinir a tag de exemplo")}</Button></form> <div class="tags" role="group" aria-label={("Tags do projeto")} >{#each model.labels as label (label.key)}<Tag color={label.protected ? 'blue' : 'default'} closeIcon closeLabel={`Delete ${label.text}`} onClose={event => remove(event, label)} >{(label.text)}</Tag>{/each}</div> <h3>{("Filtragem de tarefas")}</h3> <div class="tags" role="group" aria-label={("Filtro de tarefa pelo 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={("Tarefas com tags de status")} pagination={(false)} /></div> <output aria-label={("Exemplo de tag de resultado")}>{message}{(" Mostra a tarefa: ")}{(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', "Documentação"].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
Disponível Tag.CheckableTag e Tag.CheckableTagGroup. Ambos os componentes também podem ser importados pelo nome. Os tipos completos são publicados em @woodger/antd.
| Tema | Exemplo ou restrição |
|---|---|
| Basic | Fechamento, veto, nome e link disponíveis. |
| Colorful Tag | Paleta e cor nativa CSS-colorido em três variantes. |
| Add & Remove Dynamically | Matriz gerenciada e retorno de foco. |
| Checkable | Separar etiqueta, grupos únicos e múltiplos. |
| Animate | Adaptação ao movimento: Svelte Escala com movimento reduzido. |
| Icon | Ícone de trecho na tag e CheckableTag, possui closeIcon. |
| Status Tag | Cinco status para filled/outlined/solid. |
| Draggable Tag | Adaptação DND-KIT: botões nativos de arrastar e permutação. |
| Custom semantic dom styling | Etiqueta de design e CheckableTagGroup. |
Tag
| Propriedade | Descrição | Tipo | Valor padrão |
|---|---|---|---|
prefixCls | Completo local CSS-prefixo tag. String vazio e undefined Herdar ConfigProvider.prefixCls; Padrão ant-tag. | string | ConfigProvider + -tag |
color | Preset, status ou CSS-color. | TagColor | default |
variant | fundo, contorno ou cor sólida. | filled | outlined | solid | filled |
closable | Fechando e Aria atribui um controle próximo. | boolean | TagCloseConfig | null | false |
closeIcon | Redução para fechamento; true Inclui o ícone padrão. | TagCloseIcon | — |
closeLabel | Botão Fechamento do nome do botão, prioridade closable aria-label. | string | locale.closeText |
onClose | preventDefault Cancele o oculto integrado. | (event: MouseEvent) => void | — |
icon | Ícone decorativo na frente do conteúdo. | Snippet | — |
href | O endereço não vazio cria âncora nativa. | string | — |
disabled | Bloqueia ações; O link remove href. | boolean | contexto / false |
classNames | O objeto ou função das classes Slots. | TagSemantic | — |
styles | Objeto ou função CSS slots. | TagSemantic | — |
CheckableTag
| Propriedade | Descrição | Tipo | Valor padrão |
|---|---|---|---|
prefixCls | Completo local CSS-prefixo CheckableTag. String vazia e undefined Herdar ConfigProvider.prefixCls; Padrão ant-tag. | string | ConfigProvider + -tag |
checked | O valor é armazenado pelo proprietário; Não existe um modo não controlado interno. | boolean | false |
onChange | Switch Request após pressionar ou espaço. | (checked: boolean) => void | — |
disabled | Desabilita o botão nativo. | boolean | contexto / false |
icon | Ícone decorativo. | Snippet | — |
CheckableTagGroup
| Propriedade | Descrição | Tipo | Valor padrão |
|---|---|---|---|
prefixCls | Base local completa CSS Prefixo de grupo com sufixo -checkable-group. String vazia e undefined Herdar ConfigProvider.prefixCls; Padrão ant-tag. CheckableTag As opções herdam separadamente o prefixo comum. | string | ConfigProvider + -tag |
options | valores únicos; 1 e a linha 1 são diferentes. | readonly (Value | CheckableTagOption<Value>)[] | [] |
multiple | valor único ou matriz. | boolean | false |
value | é controlado via onChange; bind:value Não usado. | Value | null | Value[] | Estado local |
defaultValue | Valor inicial não controlado. | Value | null | Value[] | — |
onChange | O tipo de resultado depende de multiple. | (value) => void | — |
disabled | Desativa a troca de elementos. | boolean | contexto / false |
styles | raiz e item; objeto ou função. | CheckableTagGroupSemantic<Value> | — |
Tag.icon e grupo de suporte ao conteúdo do grupo. styles Defina CSS Strings. O fechamento é transmitido nativo MouseEvent; Close Config disabled e afterClose não são usados como na referência.
Semantic DOM
Tag usa span ou A, fechando o botão nativo. CheckableTag — botão com aria-pressed; Grupo mescla botões. content O slot existe quando icon está presente. CheckableTag Aceita o usual class/style.
| Slot | Atribuir |
|---|---|
root | Rótulo ou link. |
icon | ícone. |
content | Conteúdo quando disponível icon. |
close | Botão Fechar. |
| Slot | Atribuir |
|---|---|
root | Container de grupo. |
item | Criança CheckableTag. |
Tokens de design
theme.components.Tag se aplica defaultBg,defaultColor e solidTextColor. O último define o texto default solid; Cor solid Use colorTextLightSolid. Os estilos inline semânticos e convencionais mantêm a prioridade.
| Token | Atribuir |
|---|---|
defaultBg | Fundo de tag normal. |
defaultColor | Cor de marca normal. |
solidTextColor | Cor do texto default solid. |
| Token | Valor |
|---|---|
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
Como não remover a marca depois de pressionar o fechamento?
Ligue preventDefault em onClose. Se a matriz estiver armazenando o aplicativo, atualize-o você mesmo e restaure o foco após o tick.
Como armazenar filtros?
CheckableTag Obtém checked/onChange. O grupo usa value ou inicial defaultValue; multiple Especifica a matriz de resultados.
Onde as animações e permutações são implementadas?
No site Exemplos: Svelte Transição, drag nativo e botões. O React Motion/DND-Kit não é adicionado à biblioteca.
Quais configurações são herdadas?
ConfigProvider.tag Conjunto variant, fechamento e design. Registro aninhado substitui pai; CheckableTag Herda apenas class/style.