Components
Tag
Tag is a label that can be used to categorize items or communicate progress, status, or process. Tags can provide users with a quicker overview of content.
React
Press Enter to start editing
const Preview = () => { return <Tag>New</Tag>; }; render(<Preview />)
- variant
- Description
The visual variant of the tag
- Type
"default" | "outline"- Default
default
| Name | Type | Default | Description |
|---|---|---|---|
| variant | "default" | "outline" | default | The visual variant of the tag |
Usage
Examples
Sizes
React
Press Enter to start editing
const Sizes = () => { const sizes = ['sm', 'md', 'lg'] as const; return ( <> {sizes.map((size) => ( <Tag key={size} data-size={size}> {size} </Tag> ))} </> ); }; render(<Sizes />)
Icons
You must determine the spacing between text and icon yourself. We recommend that the padding on the Tag towards the outer edge is equal to the margin on the icon.
React
Press Enter to start editing
const IconsEn = () => { return ( <Tag data-color='neutral' data-size='md' style={{ paddingInlineStart: 'var(--ds-size-1)', }} > <RobotIcon aria-hidden style={{ marginInlineEnd: 'var(--ds-size-1)' }} /> This text is AI-generated </Tag> ); }; render(<IconsEn />)
Variants
You can set variant="outline" to make the tag more visible on some background colors.
React
Press Enter to start editing
const Variants = () => { const colors = [ 'accent', 'brand1', 'brand2', 'brand3', 'neutral', 'success', 'warning', 'danger', 'info', ] as TagProps['data-color'][]; return ( <> <div style={{ display: 'flex', gap: 'var(--ds-size-2)', flexWrap: 'wrap', }} > <Paragraph>Default:</Paragraph> {colors.map((color) => ( <Tag key={color} data-color={color as TagProps['data-color']} variant='default' > {color} </Tag> ))} </div> <br /> <div style={{ display: 'flex', gap: 'var(--ds-size-2)', flexWrap: 'wrap', }} > <Paragraph>Outline:</Paragraph> {colors.map((color) => ( <Tag key={color} data-color={color as TagProps['data-color']} variant='outline' > {color} </Tag> ))} </div> </> ); }; render(<Variants />)
HTML
Apply the class name ds-tag to the element that is to be a tag.
CSS variables and data attributes
| Name | Value |
|---|---|
| --dsc-tag-background | var(--ds-color-surface-tinted) |
| --dsc-tag-color | var(--ds-color-text-default) |
| --dsc-tag-min-height | var(--ds-size-8) |
| --dsc-tag-padding | 0 var(--ds-size-2) |
| --dsc-tag-border-width | var(--ds-border-width-default) |
| --dsc-tag-border-color | transparent |
| --dsc-tag-border-style | solid |
| Name | Value |
|---|---|
| data-variant | outline |