Examples
Selectable filter
A pressed state communicates whether a filter is active and can be changed by keyboard or pointer.
Selectable Billing filter
"use client";
import { useState } from "react";
import { Tag } from "@phuctech/ui/components/tag";
export function Example() {
const [selected, setSelected] = useState(false);
return <Tag label="Billing" selected={selected} onSelectedChange={setSelected} />;
}
Removable filter
Removal is a separate named action beside the toggle, never a nested button.
Removable Trial plan filter
"use client";
import { useState } from "react";
import { Tag } from "@phuctech/ui/components/tag";
export function Example() {
const [visible, setVisible] = useState(true);
return visible ? <Tag label="Trial plan" defaultSelected onRemove={() => setVisible(false)} /> : <p>Filter removed.</p>;
}
Disabled filter
A disabled value stays visible but cannot be toggled or removed.
Disabled selected filter
import { Tag } from "@phuctech/ui/components/tag";
export function Example() {
return <Tag label="Archived filter" selected disabled />;
}
Try the filter
Change the selected state and shared control density.
Tag property playground
"use client";
import { useState } from "react";
import { Tag } from "@phuctech/ui/components/tag";
export function Example() {
const [selected, setSelected] = useState(false);
return <Tag label="Product design" selected={selected} onSelectedChange={setSelected} size="md" />;
}
When to use
Use Tag for a filter or classification that people can toggle, and optionally remove from the active set. Use Badge for a static lifecycle state, role, or result label.
Usage
import { Tag } from "@phuctech/ui/components/tag";
<Tag label="Billing" selected={selected} onSelectedChange={setSelected} onRemove={removeBillingFilter} />Behavior
selected+onSelectedChangeis controlled;defaultSelectedinitializes local state when selected is omitted.onRemoveadds a separate, named IconButton after the toggle. It reports a request; feature state removes the tag.- Disabled applies to both toggle and remove actions.
- Removing a filter is a local selection change. If an action would delete a resource, confirm it through the shared Dialog pattern in the feature.
API
Tokens
Accessibility
The toggle has a visible label and exposes its pressed state. The remove action is a second button with a name that includes the tag label by default. Both actions are keyboard reachable; Escape is not required because the tag does not open a popup.
Do and don’t
Keep selection and removal as separate controls and state transitions.
Use an interactive Tag for passive status text or make the entire chip disappear without a labeled action.