- Advanced Toast
- ArrowButton
- Arrows
- Avatar
- Backdrop
- Basic Toast
- Breadcrumb
- Button
- CardBackground
- Card
- ChatButton
- Checkbox
- Checkboxes
- Chip
- ChoiceExpander
- Clickable
- Date Field
- Dropdown
- ElasticHeight
- ExpandableCard
- Filter
- FormCheckbox
- Form Control
- Form Label
- HamburgerIcon
- Heading
- Image
- Link
- Loader
- Number Field
- Pagination
- Password
- Phone Field
- Popin
- Portal
- Prose
- Radio Group
- Radio
- Range
- Select
- SidebarLayout
- Spinner
- Switch
- Tabs
- Tag
- TextField
- ValidationMessage
'use client';
import { IconsFixture } from '@clubmed/trident-icons/tests/IconsFixture';
import { Tag } from '@/ui/Tag';
export function TagDemo() {
return (
<IconsFixture>
<Tag label="New Feature" icon="Diamond" theme="both" />
</IconsFixture>
);
}
Installation
npx shadcn@latest add https://develop.trident-ui.pro.clubmed/r/tag.json
Usage
import { Tag } from '@/docs/lib/ui/tag';
export function Component() {
return (
<Tag label="New Feature" icon="Diamond" theme="both" backgroundColor="saffron" color="black" />
);
}API Reference
Tag
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | "" | The text label displayed in the tag. Used as the title attribute for accessibility. |
icon | IconicNames | undefined | Optional icon name from the Trident Icons library to display in the tag. |
theme | "label" | "icon" | "both" | "swap" | "unfold" | "monogram" | "pill" | "none" | "both" | Display mode for the tag. Controls visibility and layout of icon and label. |
backgroundColor | BgColor | string | "saffron" | Background color of the tag. Accepts 17 predefined colors: black, darkGrey, green, lavender, lightGrey, lightSand, marygold, orange, red, saffron, sand, sienna, ultramarine, verdigris, wave, white, or custom Tailwind classes. |
color | TextColor | string | "black" | Text color of the tag. Accepts the same color options as backgroundColor or custom Tailwind classes. |
border | BorderColor | string | Same as backgroundColor | Border color of the tag. Accepts the same color options as backgroundColor or custom Tailwind classes. |
iconClassName | string | undefined | Additional CSS classes for the icon element. |
iconWidth | string | "1.5rem" | Width of the icon. |
labelClassName | string | undefined | Additional CSS classes for the label element. |
className | string | undefined | Additional CSS classes for the tag container. |
Notes
-
Theme Modes: The
themeprop offers flexible display options:"label": Shows only the label with padding"icon": Shows only the icon (label used for title attribute)"both": Shows both icon and label side by side"swap": Shows icon on mobile, label on larger screens (sm breakpoint)"unfold": Shows icon always, label on larger screens (sm breakpoint)"monogram": Shows label in a circular format (24x24px)"pill": Shows label with compact pill styling (smaller text)"none": Shows both with minimal padding
-
Semantic Role: The component renders with
role="note"for accessibility, indicating informational content. -
Color Customization: All color props accept predefined color names or custom Tailwind CSS classes for maximum flexibility.
-
Conditional Rendering: The tag returns
nullif bothlabelandiconare empty, preventing empty tags from rendering. -
Smart Theme Logic: When
theme="both"is set but no icon is provided, the component automatically falls back to"label"mode. -
Responsive Design: The
swapandunfoldthemes use responsive classes to show different content at different screen sizes. -
HTML Attributes: All standard HTML span attributes are supported via
ComponentPropsWithoutRef<"span">. -
Border Inheritance: By default, the border color matches the background color unless explicitly overridden.