Tag
The Tag component represents visual labels, categories, or keywords. It supports different variants, shapes, interactive closing behavior, custom icons, and dynamic slotted content.
When To Use
- It can be used to tag by dimension or property.
- When categorizing.
Tag
Tags come in default and outline variants. By default, tags are removable.
---
import Tag from '@/components/data-display/Tag.astro';
---
<Tag label="Default Tag" removable={false} />
<Tag variant="outline" label="Outline Tag" removable={false} /> Tag
Tags support different color intents for conveying context such as primary, success, warning, danger, and info.
---
import Tag from '@/components/data-display/Tag.astro';
---
<Tag label="Primary" intent="primary" removable={false} />
<Tag label="Success" intent="success" removable={false} />
<Tag label="Warning" intent="warning" removable={false} />
<Tag label="Danger" intent="danger" removable={false} />
<Tag label="Info" intent="info" removable={false} /> Tag
Control the Tag's border radius using the shape prop (pill or square).
---
import Tag from '@/components/data-display/Tag.astro';
---
<Tag label="Pill Shape" shape="pill" />
<Tag label="Square Shape" shape="square" /> Tag
Set removable={true} (default) to show a close button. By default, it completely removes its DOM node when clicked. You can override this via onRemove prop.
---
import Tag from '@/components/data-display/Tag.astro';
---
<Tag label="Closable Tag" />
<Tag label="Alert on Close" onRemove="alert('Tag closed!'); this.parentElement.remove();" /> Tag
Add left or right icons using iconLeft and iconRight props. You can also pass dynamic content as a slot instead of using the label prop.
---
import Tag from '@/components/data-display/Tag.astro';
---
<Tag label="Search" iconLeft="Search" removable={false} />
<Tag label="Settings" iconRight="Settings" removable={false} />
<Tag removable={false}>
<div class="flex items-center gap-1.5 text-blue-600 dark:text-blue-400">
<span class="w-2 h-2 rounded-full bg-blue-500"></span>
Custom Slot Tag
</div>
</Tag> Tag
Tags can be marked as disabled to prevent interaction.
---
import Tag from '@/components/data-display/Tag.astro';
---
<Tag label="Disabled Tag" disabled /> API Reference
| Property | Description | Type | Default |
|---|---|---|---|
| variant | Visual style variant | 'default' | 'outline' | 'default' |
| intent | Color intent for context | 'default' | 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'default' |
| shape | Border radius shape | 'pill' | 'square' | 'pill' |
| disabled | Disables interactions and reduces opacity | boolean | false |
| removable | Shows a close button | boolean | true |
| label | Text content (if not using slot) | string | '-' |
| iconLeft | Icon name to show on the left | IconName | '-' |
| iconRight | Icon name to show on the right | IconName | '-' |
| onRemove | JavaScript string to execute when close is clicked | string | '-' |