Pills that pick tags, filters and Scout's suggestions in place
← → move · Enter picks · Backspace dismisses a suggestion
pnpm dlx shadcn@latest add @notchset-pro/chip-groupA few filters chosen from one short list, as chips you press.
Every shadcn style · one file
Import it and pass your content. The props that matter most are listed next.
"use client";
import * as React from "react";
import { ButtonRoll } from "@/lib/notchset/button-look";
import { ChipGroup, type ChipOption } from "@/components/ui/notchset/chip-group";
import { useLessMotion } from "@/lib/notchset/motion";
import { Orb } from "@/components/ui/notchset/orb";
import { RollingNumber } from "@/components/ui/notchset/rolling-number";
import { pressIn, useSelfPlay } from "./self-play";
/*
* The group alone, centred, in three looks. Tags: Enterprise is on; a press picks another (it widens as its check
* draws), "+5 more" unfolds the rest in the row and "Less" folds them back; on arrival Renewal is picked. Filter: one
* stage at a time, solid ink, its count in a fixed slot, the line under it rolling; on arrival Proposal is picked.
* Suggested: Scout's two suggestions arrive dashed and the first is added; a press adds one, the x dismisses it; with
* none left, Ask Scout brings the next beside Renewal and the tags after it make room.
*/
type Look = "tags" | "filter" | "suggested";
const TAGS: ChipOption<string>[] = [
{ value: "enterprise", label: "Enterprise" },
{ value: "eu", label: "EU" },
{ value: "renewal", label: "Renewal" },
{ value: "expansion", label: "Expansion" },
{ value: "fintech", label: "Fintech" },
{ value: "champion", label: "Champion" },
{ value: "security", label: "Security review" },
{ value: "q1", label: "Q1 close" },
{ value: "annual", label: "Annual plan" },
];
const STAGES: ChipOption<string>[] = [
{ value: "lead", label: "Lead", count: 9 },
{ value: "qualified", label: "Qualified", count: 6 },
{ value: "proposal", label: "Proposal", count: 12 },
{ value: "won", label: "Won", count: 4 },
];
const SUGGESTIONS: ChipOption<string>[] = [
{ value: "expansion", label: "Expansion", suggested: true },
{ value: "security", label: "Security review", suggested: true },
];
const NEXT: ChipOption<string>[] = [
{ value: "annual", label: "Annual plan", suggested: true },
{ value: "q1", label: "Q1 close", suggested: true },
];
const LINE = "mt-4 flex h-4 items-center justify-center gap-1.5 text-[length:var(--ns-text-meta)] leading-[15px] text-[var(--ns-ink-3)]";
const CHIP = "[data-chip] > button";
/* plays once on arrival: each look's own moment, pressing its own chips */
function usePlay(beats: number[], run: (step: number, root: HTMLElement | null) => void) {
const root = React.useRef<HTMLDivElement>(null);
const play = useSelfPlay(root, { beats, off: useLessMotion() });
React.useEffect(() => {
if (play.step < 0) return;
const step = play.step;
const t = setTimeout(() => run(step, root.current));
return () => clearTimeout(t);
// eslint-disable-next-line react-hooks/exhaustive-deps -- once per step
}, [play.step, play.taken]);
return { root, hand: { onPointerDownCapture: play.handOver, onKeyDownCapture: play.handOver } };
}
function Tags() {
const [value, setValue] = React.useState(["enterprise"]);
const options = TAGS;
const { root, hand } = usePlay([0], (_, el) => pressIn(el, `${CHIP}:not([aria-pressed=true])`, "Renewal"));
return (
<div ref={root} {...hand} className="flex w-full flex-col items-center">
<ChipGroup multiple label="Tags" options={options} value={value} onValueChange={setValue} max={4} more="unfold" className="justify-center" />
</div>
);
}
function Filter() {
const [value, setValue] = React.useState<string | null>(null);
const stages = STAGES;
const on = stages.find((s) => s.value === value);
const { root, hand } = usePlay([0], (_, el) => [...(el?.querySelectorAll<HTMLElement>(CHIP) ?? [])].find((b) => b.textContent?.trim().startsWith("Proposal"))?.click());
return (
<div ref={root} {...hand} className="flex w-full flex-col items-center">
<div data-swipe-off="" className="flex max-w-full justify-center">
<ChipGroup label="Filter by stage" options={stages} value={value} onValueChange={setValue} row />
</div>
<div aria-live="polite" className={LINE}>
<RollingNumber value={String(on?.count ?? stages.reduce((n, s) => n + (s.count ?? 0), 0))} />
<ButtonRoll k={on?.value ?? "all"}>{on ? `deals in ${on.label}` : "deals"}</ButtonRoll>
</div>
</div>
);
}
function Suggested() {
const [options, setOptions] = React.useState(() => TAGS.slice(0, 3));
const [value, setValue] = React.useState(["enterprise", "eu"]);
/* Scout's two suggestions arrive, then the first is added */
const { root, hand } = usePlay([0, 180, 1000], (step, el) => {
const s = SUGGESTIONS[step];
if (s) setOptions((xs) => (xs.some((x) => x.value === s.value) ? xs : [...xs, s]));
else pressIn(el, CHIP, "Expansion");
});
const left = options.filter((o) => o.suggested).length;
const next = NEXT.find((m) => !options.some((o) => o.value === m.value));
return (
<div ref={root} {...hand} className="flex w-full flex-col items-center">
<ChipGroup
multiple
label="Tags"
options={options}
value={value}
onValueChange={setValue}
className="justify-center"
onAccept={(id) => {
setOptions((xs) => xs.map((x) => (x.value === id ? { ...x, suggested: false } : x)));
setValue((v) => [...v, id]);
}}
onDismiss={(id) => setOptions((xs) => xs.filter((x) => x.value !== id))}
/>
<div aria-live="polite" className={LINE}>
<ButtonRoll k={String(left)}>{left === 0 ? "Tags up to date" : left === 1 ? "Scout suggests one, from Tuesday's call" : "Scout suggests two, from Tuesday's call"}</ButtonRoll>
{left === 0 && next ? (
<button
type="button"
onClick={() =>
setOptions((xs) => {
const at = xs.findIndex((x) => x.value === "renewal") + 1;
return at > 0 ? [...xs.slice(0, at), next, ...xs.slice(at)] : [...xs, next];
})
}
className="ms-1 inline-flex h-6 cursor-pointer items-center gap-1.5 rounded-full px-2 text-[length:var(--ns-text-meta)] font-[number:var(--ns-weight-medium)] text-[var(--ns-ink-2)] outline-hidden transition-colors hover:bg-[var(--ns-hover)] hover:text-[var(--ns-ink)] focus-visible:outline-2 focus-visible:outline-[var(--ns-signal)] pointer-coarse:h-11"
>
<Orb size={12} word="none" live={false} tint="Scout" />
Ask Scout
</button>
) : null}
</div>
</div>
);
}
export default function ChipGroupDemo() {
const look = "tags" as Look;
const Stage = { tags: Tags, filter: Filter, suggested: Suggested }[look] ?? Tags;
/* one column for every look, its height held to the tallest, so the stage never changes height */
return (
<div className="flex min-h-[160px] w-[720px] max-w-full flex-col justify-center">
<Stage key={look} />
</div>
);
}"use client";
import * as React from "react";
import { ButtonRoll } from "@/lib/notchset/button-look";
import { ChipGroup, type ChipOption } from "@/components/ui/notchset/chip-group";
import { useLessMotion } from "@/lib/notchset/motion";
import { Orb } from "@/components/ui/notchset/orb";
import { RollingNumber } from "@/components/ui/notchset/rolling-number";
import { pressIn, useSelfPlay } from "./self-play";
/*
* The group alone, centred, in three looks. Tags: Enterprise is on; a press picks another (it widens as its check
* draws), "+5 more" unfolds the rest in the row and "Less" folds them back; on arrival Renewal is picked. Filter: one
* stage at a time, solid ink, its count in a fixed slot, the line under it rolling; on arrival Proposal is picked.
* Suggested: Scout's two suggestions arrive dashed and the first is added; a press adds one, the x dismisses it; with
* none left, Ask Scout brings the next beside Renewal and the tags after it make room.
*/
type Look = "tags" | "filter" | "suggested";
const TAGS: ChipOption<string>[] = [
{ value: "enterprise", label: "Enterprise" },
{ value: "eu", label: "EU" },
{ value: "renewal", label: "Renewal" },
{ value: "expansion", label: "Expansion" },
{ value: "fintech", label: "Fintech" },
{ value: "champion", label: "Champion" },
{ value: "security", label: "Security review" },
{ value: "q1", label: "Q1 close" },
{ value: "annual", label: "Annual plan" },
];
const STAGES: ChipOption<string>[] = [
{ value: "lead", label: "Lead", count: 9 },
{ value: "qualified", label: "Qualified", count: 6 },
{ value: "proposal", label: "Proposal", count: 12 },
{ value: "won", label: "Won", count: 4 },
];
const SUGGESTIONS: ChipOption<string>[] = [
{ value: "expansion", label: "Expansion", suggested: true },
{ value: "security", label: "Security review", suggested: true },
];
const NEXT: ChipOption<string>[] = [
{ value: "annual", label: "Annual plan", suggested: true },
{ value: "q1", label: "Q1 close", suggested: true },
];
const LINE = "mt-4 flex h-4 items-center justify-center gap-1.5 text-[length:var(--ns-text-meta)] leading-[15px] text-[var(--ns-ink-3)]";
const CHIP = "[data-chip] > button";
/* plays once on arrival: each look's own moment, pressing its own chips */
function usePlay(beats: number[], run: (step: number, root: HTMLElement | null) => void) {
const root = React.useRef<HTMLDivElement>(null);
const play = useSelfPlay(root, { beats, off: useLessMotion() });
React.useEffect(() => {
if (play.step < 0) return;
const step = play.step;
const t = setTimeout(() => run(step, root.current));
return () => clearTimeout(t);
// eslint-disable-next-line react-hooks/exhaustive-deps -- once per step
}, [play.step, play.taken]);
return { root, hand: { onPointerDownCapture: play.handOver, onKeyDownCapture: play.handOver } };
}
function Tags() {
const [value, setValue] = React.useState(["enterprise"]);
const options = TAGS;
const { root, hand } = usePlay([0], (_, el) => pressIn(el, `${CHIP}:not([aria-pressed=true])`, "Renewal"));
return (
<div ref={root} {...hand} className="flex w-full flex-col items-center">
<ChipGroup multiple label="Tags" options={options} value={value} onValueChange={setValue} max={4} more="unfold" className="justify-center" />
</div>
);
}
function Filter() {
const [value, setValue] = React.useState<string | null>(null);
const stages = STAGES;
const on = stages.find((s) => s.value === value);
const { root, hand } = usePlay([0], (_, el) => [...(el?.querySelectorAll<HTMLElement>(CHIP) ?? [])].find((b) => b.textContent?.trim().startsWith("Proposal"))?.click());
return (
<div ref={root} {...hand} className="flex w-full flex-col items-center">
<div data-swipe-off="" className="flex max-w-full justify-center">
<ChipGroup label="Filter by stage" options={stages} value={value} onValueChange={setValue} row />
</div>
<div aria-live="polite" className={LINE}>
<RollingNumber value={String(on?.count ?? stages.reduce((n, s) => n + (s.count ?? 0), 0))} />
<ButtonRoll k={on?.value ?? "all"}>{on ? `deals in ${on.label}` : "deals"}</ButtonRoll>
</div>
</div>
);
}
function Suggested() {
const [options, setOptions] = React.useState(() => TAGS.slice(0, 3));
const [value, setValue] = React.useState(["enterprise", "eu"]);
/* Scout's two suggestions arrive, then the first is added */
const { root, hand } = usePlay([0, 180, 1000], (step, el) => {
const s = SUGGESTIONS[step];
if (s) setOptions((xs) => (xs.some((x) => x.value === s.value) ? xs : [...xs, s]));
else pressIn(el, CHIP, "Expansion");
});
const left = options.filter((o) => o.suggested).length;
const next = NEXT.find((m) => !options.some((o) => o.value === m.value));
return (
<div ref={root} {...hand} className="flex w-full flex-col items-center">
<ChipGroup
multiple
label="Tags"
options={options}
value={value}
onValueChange={setValue}
className="justify-center"
onAccept={(id) => {
setOptions((xs) => xs.map((x) => (x.value === id ? { ...x, suggested: false } : x)));
setValue((v) => [...v, id]);
}}
onDismiss={(id) => setOptions((xs) => xs.filter((x) => x.value !== id))}
/>
<div aria-live="polite" className={LINE}>
<ButtonRoll k={String(left)}>{left === 0 ? "Tags up to date" : left === 1 ? "Scout suggests one, from Tuesday's call" : "Scout suggests two, from Tuesday's call"}</ButtonRoll>
{left === 0 && next ? (
<button
type="button"
onClick={() =>
setOptions((xs) => {
const at = xs.findIndex((x) => x.value === "renewal") + 1;
return at > 0 ? [...xs.slice(0, at), next, ...xs.slice(at)] : [...xs, next];
})
}
className="ms-1 inline-flex h-6 cursor-pointer items-center gap-1.5 rounded-full px-2 text-[length:var(--ns-text-meta)] font-[number:var(--ns-weight-medium)] text-[var(--ns-ink-2)] outline-hidden transition-colors hover:bg-[var(--ns-hover)] hover:text-[var(--ns-ink)] focus-visible:outline-2 focus-visible:outline-[var(--ns-signal)] pointer-coarse:h-11"
>
<Orb size={12} word="none" live={false} tint="Scout" />
Ask Scout
</button>
) : null}
</div>
</div>
);
}
export default function ChipGroupDemo() {
const look = "tags" as Look;
const Stage = { tags: Tags, filter: Filter, suggested: Suggested }[look] ?? Tags;
/* one column for every look, its height held to the tallest, so the stage never changes height */
return (
<div className="flex min-h-[160px] w-[720px] max-w-full flex-col justify-center">
<Stage key={look} />
</div>
);
}"use client";
import * as React from "react";
/*
* A demo that plays itself until the first touch: the script lives in the demo, never in the piece, which only gets
* the props a person would give it. It moves 0.4 s after the piece is first seen, then takes each step on its beat;
* off screen or paused it waits. The first press, key or focus on the piece (bind `handOver` to it; a scroll over it never counts) makes it the
* visitor's for good and drops every queued step; with less motion (`off`) it never plays and rests in its first frame.
* A host can hand it over from outside the piece too (a settings panel beside it the visitor has used): under
* <HandedOver value>, it never plays, a remount included.
*
* const play = useSelfPlay(root, { beats: [2800, 2800], loop: true, off: less });
* <div ref={root} onPointerDownCapture={play.handOver} onKeyDownCapture={play.handOver} onFocusCapture={play.handOver}>
* play.step // the step it is at, -1 before its first
* play.control // "pause" while it plays, "play" once paused (a new take), "replay" once it is over or yours
*
* Each step presses the piece's own controls (pressIn), so the script shows exactly what a hand can do.
*
* A host that shows the piece once (<PlayOnce value={{ settle }}>) changes three things: the script starts when the
* piece is first half in view and never again on coming back, it never loops, and with less motion (or `settle`) it
* takes every step at once, so the piece rests on the END of its moment. `hold` is a reason not to play at all that is
* not motion (a mode with nothing to show): it holds in every host. Under <PlayOnce value={{ active: false }}> (a look
* that is mounted but not shown) it waits until it is shown.
*/
type SelfPlayOptions = {
/** how long each step waits after the one before it, in ms; the first step waits 0.4 s after the piece is seen */
beats: readonly number[];
/** starts over after the last step; without it the script plays once and rests */
loop?: boolean | undefined;
/** no self-play at all (less motion): the piece is the visitor's from the start */
off: boolean;
/** no self-play for a reason other than motion (a mode with nothing to show), in every host */
hold?: boolean | undefined;
};
/** How a host shows the piece: once on arrival (see useSelfPlay). */
type PlayOnceHost = {
/** rest on the end at once, without playing (less motion, or a reset) */
settle?: boolean | undefined;
/** false while the piece is mounted but not shown: it waits */
active?: boolean | undefined;
};
const START = 400;
/**
* Whether a demo plays itself at all. Off: every piece rests in its first frame and is
* the visitor's from the start; nothing presses its controls for them.
*/
const SELF_PLAY: boolean = false;
/** True where the visitor has already taken the piece from outside it: nothing under it plays itself. */
const HandedOver = React.createContext(false);
/** A host that shows the piece once: play once on arrival, rest on the end (null: play as the demo asks). */
const PlayOnce = React.createContext<PlayOnceHost | null>(null);
function useSelfPlay(root: React.RefObject<Element | null>, { beats, loop: looped = false, off: still, hold = false }: SelfPlayOptions) {
const once = React.useContext(PlayOnce);
const active = once?.active !== false;
/* shown once: less motion (or a settled host) takes every step at once and rests on the end */
const quick = once != null && (still || Boolean(once.settle));
const loop = once == null && looped;
/* the first touch hands it over for good */
const [mine, setMine] = React.useState(false);
const handOver = React.useCallback(() => setMine(true), []);
const handedOver = React.useContext(HandedOver);
const off = !SELF_PLAY || hold || (quick ? false : still) || mine || (handedOver && !quick);
const [seen, setSeen] = React.useState(false);
const [paused, setPaused] = React.useState(false);
const [taken, setTaken] = React.useState(0);
const n = Math.max(1, beats.length);
const done = !loop && taken >= n;
React.useEffect(() => {
const el = root.current;
if (!active) return;
/* without an observer (an old browser, a test) it counts as seen */
if (!el || typeof IntersectionObserver === "undefined" || quick) {
const t = window.setTimeout(() => setSeen(true));
return () => window.clearTimeout(t);
}
/* shown once: first half in view starts it, and leaving never stops or restarts it */
const io = once
? new IntersectionObserver((es) => {
if (es.some((e) => e.isIntersecting && e.intersectionRatio >= 0.5)) {
setSeen(true);
io.disconnect();
}
}, { threshold: 0.5 })
: new IntersectionObserver((es) => setSeen(es.some((e) => e.isIntersecting)));
io.observe(el);
return () => io.disconnect();
}, [root, active, once, quick]);
const playing = !off && seen && active && !paused && !done;
const delay = quick ? 0 : taken === 0 ? START : (beats[taken % n] ?? START);
React.useEffect(() => {
if (!playing) return;
const t = window.setTimeout(() => setTaken((k) => k + 1), delay);
return () => window.clearTimeout(t);
}, [playing, taken, delay]);
/* one control in one place: Pause while it plays, Play (a new take) once paused, Replay once it is over or yours */
/* self-play off: never "over", so a demo rests in its FIRST frame, not its end frame */
const control: "pause" | "play" | "replay" = paused || !SELF_PLAY ? "play" : off || done ? "replay" : "pause";
return { step: taken === 0 ? -1 : (taken - 1) % n, taken, playing, control, mine, handOver, pause: () => setPaused(true) };
}
/**
* Presses a real control inside `root`, as the visitor would: the first match of `selector`, or the one whose text is
* `text`. A click only, so it never counts as the visitor's touch.
*/
function pressIn(root: Element | null, selector: string, text?: string) {
const all = [...(root?.querySelectorAll<HTMLElement>(selector) ?? [])];
(text == null ? all[0] : all.find((el) => el.textContent?.trim() === text))?.click();
}
export { HandedOver, PlayOnce, pressIn, useSelfPlay, type PlayOnceHost, type SelfPlayOptions };This example also uses Button, Rolling number. This command installs them with it, so the example pastes as it is:
pnpm dlx shadcn@latest add @notchset-pro/chip-group @notchset/button @notchset/rolling-numbercomponents/ui/notchset/chip-group.tsx
This component is included with Pro.
Try the live preview above. Get Pro to install the source.
LevelOrganism: made of molecules or blocks.
Needs your registry key. Every components.json style gets the same files.
Works with React 18.3 or 19 on Tailwind CSS v4, in any shadcn project. What's tested
The CLI adds the styles to the CSS file named in components.json (tailwind.css). Check that it points at your global stylesheet, that the project uses Tailwind CSS v4, and that the file is imported in your root layout. Installed by hand: paste styles.css into that file.
options–
ChipOption<V>[]Required.
label–
stringNames the group for screen readers ("Due").
max–
numberhow many chips show before the rest sit behind a "+N more" chip; every chip shows when it is left off or the list fits
more–
"menu" | "unfold"what "+N more" does: open the rest as a menu (the default), or unfold them in the row, with "Less" to fold back
row–
booleanone line that scrolls sideways, its ends fading, instead of wrapping
loading–
booleanthe loading form: each chip a bone of its own width; they read in left to right when it turns false
onAccept–
(value: V) => voida suggestion accepted (it becomes a tag: the host clears `suggested` and turns it on)
onDismiss–
(value: V) => voida suggestion dismissed (the host takes it out of `options`)
agent–
stringthe agent that makes the suggestions, named in their words and tinting its orb
labels–
Partial<ChipGroupLabels>its built-in words (CHIP_GROUP_LABELS), English by default
locale–
stringhow the counts are written (en-US by default, never the viewer's)
multiple–
true | falsevalue–
V[] | V | nullthe chips turned on (controlled), with onValueChange
defaultValue–
V[] | V | nullonValueChange–
(value: V[]) => void | (value: V | null) => voidrequired–
booleanone chip always stays on: pressing the chosen one does nothing
Three usesquick filters over a list (Due: Today, This week, Overdue) · a stage filter where none means any · tags picked on a log, or a period that always has one chosen (Week, Month, Quarter)
Give your coding assistant the Markdown guide instead of screenshots.
https://notchset.dev/api/mcp (setup)One payment, lifetime.
v2.0.0 · 2026-10-13
Released with the Notchset system.