AI & workflow
Criterion Chip
Structured criterion produced by AI search: muted key + value, removable. 32px, radius 12.
react-aria-componentslucide-react
Preview
RoleVP SalesIndustryB2B SaaSEmployees50–500LocationUnited States
"use client";
import { useState } from "react";
import { CriterionChip } from "@/components/ui/criterion-chip";
const initial = [
{ label: "Role", value: "VP Sales" },
{ label: "Industry", value: "B2B SaaS" },
{ label: "Employees", value: "50–500" },
{ label: "Location", value: "United States" },
];
export default function Example() {
const [items, setItems] = useState(initial);
return (
<div className="flex max-w-xl flex-wrap justify-center gap-2">
{items.map((c) => (
<CriterionChip key={c.label} {...c} onRemove={() => setItems((x) => x.filter((y) => y.label !== c.label))} />
))}
{items.length === 0 && (
<button className="text-sm font-medium text-accent-text hover:underline" onClick={() => setItems(initial)}>
Reset criteria
</button>
)}
</div>
);
}Installation
Components are copied into your project — no runtime package.
Install the following dependencies:
terminalnpm install react-aria-components lucide-reactCreate a
criterion-chip.tsxfile and paste the following code into it.src/components/ui/criterion-chip.tsx"use client"; import { X } from "lucide-react"; import { Button as AriaButton } from "react-aria-components"; import { cx } from "@/utils/cx"; export interface CriterionChipProps { /** Muted key, e.g. "Role". */ label: string; value: string; onRemove?: () => void; className?: string; } /** Structured criterion produced by AI search: muted key + value, removable. 32px, radius 12. */ export function CriterionChip({ label, value, onRemove, className }: CriterionChipProps) { return ( <span className={cx("inline-flex h-8 items-center gap-2 rounded-md border border-line bg-surface pl-3 text-base font-medium", onRemove ? "pr-1.5" : "pr-3", className)}> <span className="text-fg-muted">{label}</span> <span className="text-fg">{value}</span> {onRemove && ( <AriaButton aria-label={`Remove ${label}: ${value}`} onPress={onRemove} className="inline-flex size-5 items-center justify-center rounded-xs text-fg-muted outline-none data-hovered:bg-muted data-hovered:text-fg data-focus-visible:shadow-focus" > <X className="size-3.5" /> </AriaButton> )} </span> ); }Add the theme tokens and the
cxhelper from Installation if you haven’t yet, then update the import paths to match your project setup.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| label | string | — | Muted key, e.g. “Role”. |
| value | string | — | Criterion value. |
| onRemove | () => void | — | Shows the remove button when set. |