Tag
Tag labels records with compact metadata or removable filters.
@duskmoon-dev/components/tag Usage
When to use
- Use it to clarify state, metadata, content hierarchy, or loading without creating a new workflow.
- Pair it with semantic content so visual treatment never becomes the only source of meaning.
Implementation notes
Features
Focuses on status, metadata, empty/loading states, or content grouping without owning application state.
Uses DuskMoon tokens so the component follows the active docs theme.
Tag is most often configured through `color`, `icon`, `closable`, `onClose`.
Renders with default chip classes
Feature Demos
Feature demos are authored for the component page, then supplemented with behavior scenarios from the component test coverage.
Colors
Tag supports the full semantic color palette: primary, secondary, tertiary, accent, neutral, base, info, success, warning, error.
import "@duskmoon-dev/components/styles.css";
import { Tag } from "@duskmoon-dev/components/tag";
const colors = [
"primary",
"secondary",
"tertiary",
"accent",
"neutral",
"base",
"info",
"success",
"warning",
"error"
] as const;
export function TagColorsDemo() {
return (<div style={{ display: "flex", gap: 8, flexWrap: "wrap" }}>
{colors.map((color) => (
<Tag key={color} color={color}>
{color}
</Tag>
))}
</div>);
} Basic usage
Import the component stylesheet and Tag from its package subpath, then render it with the core props.
import "@duskmoon-dev/components/styles.css";
import { Tag } from "@duskmoon-dev/components/tag";
export function Example() {
return (<Tag
color="primary"
>
DuskMoon Tag
</Tag>);
} Renders with default chip classes
test-backedTag scenario from the component test coverage: renders with default chip classes.
import "@duskmoon-dev/components/styles.css";
import { Tag } from "@duskmoon-dev/components/tag";
export function TagRendersWithDefaultChipDemo() {
return (<Tag
// Renders with default chip classes
color="primary"
>
DuskMoon Tag
</Tag>);
} Applies color class
test-backedTag scenario from the component test coverage: applies color class.
import "@duskmoon-dev/components/styles.css";
import { Tag } from "@duskmoon-dev/components/tag";
export function TagAppliesColorClassDemo() {
return (<Tag
// Applies color class
color="primary"
>
DuskMoon Tag
</Tag>);
} Applies custom className
test-backedTag scenario from the component test coverage: applies custom classname.
import "@duskmoon-dev/components/styles.css";
import { Tag } from "@duskmoon-dev/components/tag";
export function TagAppliesCustomClassNameDemo() {
return (<Tag
// Applies custom className
color="primary"
>
DuskMoon Tag
</Tag>);
} Renders icon with chip icon class
test-backedTag scenario from the component test coverage: renders icon with chip icon class.
import "@duskmoon-dev/components/styles.css";
import { Tag } from "@duskmoon-dev/components/tag";
export function TagRendersIconWithChipDemo() {
return (<Tag
// Renders icon with chip icon class
color="primary"
>
DuskMoon Tag
</Tag>);
} Renders close control and calls onClose
test-backedTag scenario from the component test coverage: renders close control and calls onclose.
import "@duskmoon-dev/components/styles.css";
import { Tag } from "@duskmoon-dev/components/tag";
export function TagRendersCloseControlAndDemo() {
return (<Tag
// Renders close control and calls onClose
color="primary"
>
DuskMoon Tag
</Tag>);
} Tag.CheckableTag reflects checked state and reports next value
test-backedTag scenario from the component test coverage: tag.checkabletag reflects checked state and reports next value.
import "@duskmoon-dev/components/styles.css";
import { Tag } from "@duskmoon-dev/components/tag";
export function TagTagCheckableTagReflectsCheckedDemo() {
return (<Tag
// Tag.CheckableTag reflects checked state and reports next value
color="primary"
>
DuskMoon Tag
</Tag>);
} Theme aware
Docs previews inherit the DuskMoon data-theme value. Use the header switch to compare light and dark rendering.
<div data-theme="sunshine">
<Tag
color="primary"
>
DuskMoon Tag
</Tag>
</div>
<div data-theme="moonlight">
<Tag
color="primary"
>
DuskMoon Tag
</Tag>
</div> API
The API reference below lists every parsed exported type or interface for Tag. Start with `color`, `icon`, `closable`, `onClose` for common usage.
packages/components/src/components/tag/Tag.types.ts
Scenarios: packages/components/src/components/tag/Tag.test.tsx | Prop | Type | Required | Description |
|---|---|---|---|
color | TagType | No | color configures Tag. |
icon | ReactNode | No | icon configures Tag. |
closable | boolean | No | closable configures Tag. |
onClose | (event: MouseEvent<HTMLButtonElement>) => void | No | onClose configures Tag. |
closeIcon | ReactNode | No | closeIcon configures Tag. |
bordered | boolean | No | bordered configures Tag. |
| Prop | Type | Required | Description |
|---|---|---|---|
checked | boolean | No | checked configures Tag. |
onChange | (checked: boolean) => void | No | onChange configures Tag. |
disabled | boolean | No | disabled configures Tag. |
| "primary" | "secondary" | "tertiary" | "accent" | "neutral" | "base" | "info" | "success" | "warning" | "error" TagColor | (string & {}) ForwardRefExoticComponent< CheckableTagProps & RefAttributes<HTMLSpanElement> > ForwardRefExoticComponent< TagProps & RefAttributes<HTMLSpanElement> > & { CheckableTag: CheckableTagComponent