Data display
Counter
Navigation and tab counts. 20px pill, 12 Medium.
Preview
121212
import { Counter } from "@/components/ui/counter";
export default function Example() {
return (
<div className="flex items-center gap-3">
<Counter>12</Counter>
<Counter tone="accent">12</Counter>
<Counter tone="alert">12</Counter>
</div>
);
}Installation
Components are copied into your project — no runtime package.
Create a
counter.tsxfile and paste the following code into it.src/components/ui/counter.tsximport { cx } from "@/utils/cx"; export interface CounterProps { /** `muted` for counts, `accent` for selection, `alert` for unread. */ tone?: "muted" | "accent" | "alert"; className?: string; children: number | string; } /** Navigation and tab counts. 20px pill, 12 Medium. */ export function Counter({ tone = "muted", className, children }: CounterProps) { return ( <span className={cx( "inline-flex h-5 min-w-5 items-center justify-center rounded-full px-1.5 text-sm font-medium tabular", tone === "muted" && "bg-muted text-fg-secondary", tone === "accent" && "bg-accent text-fg-inverse", tone === "alert" && "bg-error text-fg-inverse", className, )} > {children} </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.