Show · Tag
Tag
Tag component is used to display a collection of concise information for rapid identification and grouping.
Demos
How to import
Basic usage
To use this tag, just wrap the content with the
It can be turned into a closable label by adding the
At this time, clicking x to close will trigger the onClose event, and blocking the default event in onClose can make it still show and not hide after clicking
<Tag> tag.It can be turned into a closable label by adding the
closable property.At this time, clicking x to close will trigger the onClose event, and blocking the default event in onClose can make it still show and not hide after clicking
Size
Supports two sizes:
large and small (default).Shape
Supports two Shape:
square(default)、circle。Color
Tag supports 16 colors including whites from Semi's palette:
amber, blue, cyan, green, grey, indigo, light-blue, light-green, lime, orange, pink, purple, red, teal, violet, yellow, white. You can also customize color through style.AI style - colorful labels
Set
colorful to true to get colorful labels.Type
Tag supports three different types, including:
light(default), ghost, solid.Avatar Tag
You can get a avatar tag with
avatarSrc property. avatarShape can change the shape of avatar tag including square(default) and circle.Invisible
You can use
visible property to control whether the tag is visible.TagGroup
You can pass in configs for tags through
Set the
tagList to create a TagGroup. The maxTagCount can be used to cap the number of list and will be displayed as +N when the limit is exceeded.Set the
showPopover property to control whether the remaining content is displayed by Popover when hover to + N TagIf the tags in the TagGroup can be deleted, the user needs to process the
tagList passed to the TagGroup in onTagCloseSplitTagGroup
Use
SplitTagGroup to combine multiple tags into a single connected group. The first and last tags keep their rounded corners while the middle tags are rendered with a square edge, producing a continuous visual unit.API Reference
Tag
| Properties | Instructions | type | Default | Version |
|---|---|---|---|---|
| avatarShape | Shape of avatar tag, one of square and circle | string | square | - |
| avatarSrc | Source address of avatar tag | string | - | - |
| className | Class name | string | ||
| closable | Toggle whether the tag can be closed | boolean | false | |
| color | Color of tags, one of amber、 blue、 cyan、 green、 grey、 indigo、 light-blue、 light-green、 lime、 orange、 pink、 purple、 red、 teal、 violet、 yellow、 white | string | grey | |
| colorful | Colorful labels | boolean | false | 2.86.0 |
| gradient | Whether it is a gradient color, it needs to take effect when colorful is true | boolean | false | 2.86.0 |
| prefixIcon | prefix icon | ReactNode | 2.44.0 | |
| suffixIcon | suffix icon | ReactNode | 2.44.0 | |
| shape | Shape of tag, one of square、 circle | string | square | 2.20.0 |
| size | Size, one of small, large | string | small | |
| style | Inline style | object | ||
| type | Style type, one of ghost, solid, light | string | light | |
| visible | Toggle the visibility of the tag | boolean | true | |
| tagKey | The key required by React, as the unique identifier of each tag, does not allow repetition | string | number | |
| onClick | Callback function when clicking the tag | (e: MouseEvent) => void | - | |
| onClose | Callback function when the tag is closed | (tagChildren: ReactNode, e: MouseEvent, tagKey: string | number ) => void | - | tagKey is available in v2.18.0 |
TagGroup
| Properties | Instructions | type | Default | Version |
|---|---|---|---|---|
| avatarShape | Shape of avatar tag, one of square and circle | string | square | - |
| className | Class name | string | ||
| maxTagCount | Cap number to display, shown as + N when exceeded | number | ||
| popoverProps | Popover configuration properties, you can control the popup props like direction, zIndex, trigger, refer to Popover | PopoverProps | {} | |
| showPopover | When hover to + N, whether to display the remaining content through Popover | boolean | false | |
| size | Size, one of small, large | string | small | |
| style | Inline style | CSSProperties | ||
| tagList | Label Group data | (TagProps)[] | ||
| onTagClose | The callback function when deleting the Tag in the TagGroup | (tagChildren: ReactNode, e: MouseEvent, tagKey: string | number ) => void | - | 2.18.0 |
SplitTagGroup
| Property | Description | Type | Default | Version |
|---|---|---|---|---|
| className | Class name | string | 2.97.0 | |
| style | Inline style | CSSProperties | 2.97.0 | |
| children | Tag group content | ReactNode | 2.97.0 | |
| aria-label | Accessibility label | string | 2.97.0 |
Accessibility
ARIA
aria-labelis used to indicate the role ofTag, for deleteable or clickableTag, we recommend using this attribute
Keyboard and Focus
- If the current
Tagis interactive, then thisTagcan be focused. Such as:- When the
onClickattribute is used, the keyboard user can activate thisTagwith theEnterkeys - When the
closableproperty istrue, keyboard users can delete thisTagby pressing theDeletekey - When a
Tagis focused, keyboard users can use theEsckey to defocus the currently focusedTag
- When the
Content Guidelines
- Due to limited space, label text should be as short as possible
- avoid line breaks
- use sentence case