Back to Ant Design

Tag

components/tag/index.en-US.md

6.3.74.0 KB
Original Source

When To Use

  • It can be used to tag by dimension or property.

  • When categorizing.

Examples

<!-- prettier-ignore -->

<code src="./demo/basic.tsx">Basic</code> <code src="./demo/colorful.tsx">Colorful Tag</code> <code src="./demo/control.tsx">Add & Remove Dynamically</code> <code src="./demo/checkable.tsx">Checkable</code> <code src="./demo/animation.tsx">Animate</code> <code src="./demo/icon.tsx">Icon</code> <code src="./demo/status.tsx">Status Tag</code> <code src="./demo/customize.tsx" debug>Customize close</code> <code src="./demo/draggable.tsx">Draggable Tag</code> <code src="./demo/component-token.tsx" debug>Component Token</code> <code src="./demo/disabled.tsx" debug>Disabled</code> <code src="./demo/style-class.tsx" version="6.0.0">Custom semantic dom styling</code>

API

Common props ref:Common props

Tag

PropertyDescriptionTypeDefaultVersion
classNamesCustomize class for each semantic structure inside the component. Supports object or function.Record<SemanticDOM, string> | (info: { props })=> Record<SemanticDOM, string>-
closeIconCustom close icon. 5.7.0: close button will be hidden when setting to null or falseReactNodefalse4.4.0
colorColor of the Tagstring-
disabledWhether the tag is disabledbooleanfalse6.0.0
hrefThe address to jump when clicking, when this property is specified, the tag component will be rendered as an <a> tagstring-6.0.0
iconSet the icon of tagReactNode-
onCloseCallback executed when tag is closed (can be prevented by e.preventDefault())(e: React.MouseEvent<HTMLElement, MouseEvent>) => void-
stylesCustomize inline style for each semantic structure inside the component. Supports object or function.Record<SemanticDOM, CSSProperties> | (info: { props })=> Record<SemanticDOM, CSSProperties>-
targetSame as target attribute of a, works when href is specifiedstring-6.0.0
variantVariant of the tag'filled' | 'solid' | 'outlined''filled'6.0.0
borderedWhether has border style, please use variant="filled" insteadbooleantrue-

Tag.CheckableTag

PropertyDescriptionTypeDefaultVersion
checkedChecked status of Tagbooleanfalse
iconSet the icon of tagReactNode-5.27.0
onChangeCallback executed when Tag is checked/unchecked(checked) => void-

Tag.CheckableTagGroup

PropertyDescriptionTypeDefaultVersion
classNamesCustomize class for each semantic structure inside the component. Supports object or function.Record<SemanticDOM, string> | (info: { props }) => Record<SemanticDOM, string>-
defaultValueInitial valuestring | number | Array<string | number> | null-
disabledDisable check/uncheckboolean-
multipleMultiple select modeboolean-
optionsOption listArray<{ label: ReactNode; value: string | number } | string | number>-
stylesCustomize inline style for each semantic structure inside the component. Supports object or function.Record<SemanticDOM, CSSProperties> | (info: { props }) => Record<SemanticDOM, CSSProperties>-
valueValue of checked tag(s)string | number | Array<string | number> | null-
onChangeCallback when Tag is checked/unchecked(value: string | number | Array<string | number> | null) => void-

Semantic DOM

Tag

<code src="./demo/_semantic.tsx" simplify="true"></code>

Tag.CheckableTagGroup {#semantic-group}

<code src="./demo/_semantic_group.tsx" simplify="true"></code>

Design Token

<ComponentTokenTable component="Tag"></ComponentTokenTable>