A row of controls walked as one stop with arrows
Tab to a bar, then ← → walk it; Space latches a style
pnpm dlx shadcn@latest add https://notchset.dev/r/toolbar.jsonA row of controls that is one tab stop, walked with the arrow keys.
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 { Bold, ChevronLeft, ChevronRight, Italic, Underline } from "@/lib/notchset/icons";
import { Button } from "@/components/ui/notchset/button";
import { IconButton } from "@/components/ui/notchset/icon-button";
import { ButtonRoll } from "@/lib/notchset/button-look";
import { useLessMotion } from "@/lib/notchset/motion";
import { Toolbar } from "@/components/ui/notchset/toolbar";
import { TooltipProvider } from "@/components/ui/notchset/tooltip";
import { pressIn, useSelfPlay } from "./self-play";
import { DAY_MS, dayMs, useToday } from "./today";
/*
* The toolbar alone: two joined bars side by side, the calendar's ‹ Today › (hover or focus it for the date; the
* chevrons step the day and roll it in) and the text style's Bold, Italic and Underline, each a toggle that latches by
* sinking and stays sunk until pressed again; ⌘B, ⌘I and ⌘U (Ctrl off a Mac) run them while the hand is on the stage,
* the open tip's cap sinking. Each bar is one tab stop; the arrows (Home, End) walk its buttons. On
* arrival Italic latches once (with less motion, at once); then it is yours. Shown enlarged on a wide stage, true size
* on a phone. `apart` draws the same bars as separate buttons. The bar a selection raises over a list is Bulk bar's.
*/
const DAY = new Intl.DateTimeFormat("en-GB", { weekday: "short", day: "numeric", month: "short", timeZone: "UTC" });
const part = (parts: Intl.DateTimeFormatPart[], t: Intl.DateTimeFormatPartTypes) => parts.find((p) => p.type === t)?.value ?? "";
/** a day as the bar prints it, "Thu 12 Nov", in three parts so the cell can reserve the widest of each */
export const dayParts = (ms: number) => {
const p = DAY.formatToParts(ms);
return [part(p, "weekday"), part(p, "day"), part(p, "month")] as const;
};
export const fmtDay = (ms: number) => dayParts(ms).join(" ");
/* every weekday, day of the month and month the label can show (a 2026 sweep covers them all) */
const Y = Date.UTC(2026, 0, 1);
const every = (i: 0 | 1 | 2, n: number) => [...new Set(Array.from({ length: n }, (_, d) => dayParts(Y + d * 86_400_000)[i]))];
export const SIZES = { weekday: every(0, 7), day: every(1, 31), month: every(2, 365) };
/* the label's box: as wide as the widest label it can show, measured by the type itself (invisible copies of every
weekday, day and month, stacked), so the words change inside a box that never moves */
const stack = (all: string[]) => (
<span className="inline-grid">
{all.map((x) => (
<span key={x} className="[grid-area:1/1]">
{x}
</span>
))}
</span>
);
function DayLabel({ words, less }: { words: string; less: boolean }) {
return (
<span data-slot="toolbar-day" className="inline-grid justify-items-center">
<span aria-hidden data-slot="toolbar-day-sizer" className="invisible whitespace-nowrap [grid-area:1/1]">
{stack(SIZES.weekday)} {stack(SIZES.day)} {stack(SIZES.month)}
</span>
<span aria-hidden className="invisible [grid-area:1/1]">
Today
</span>
<span className="[grid-area:1/1] whitespace-nowrap">
{less ? (
words
) : (
/* the old word rolls out as the new rolls in, inside the reserved box: no clip, no width change */
<ButtonRoll k={words} className="!w-auto">
{words}
</ButtonRoll>
)}
</span>
</span>
);
}
export default function ToolbarDemo() {
const apart = false as boolean;
const less = useLessMotion();
const variant = apart ? "separate" : "joined";
const [offset, setOffset] = React.useState(0);
const [peek, setPeek] = React.useState(false);
const [on, setOn] = React.useState({ bold: true, italic: false, underline: false });
const flip = (k: keyof typeof on) => () => setOn((x) => ({ ...x, [k]: !x[k] }));
const today = dayMs(useToday("2026-11-12"));
const words = offset === 0 && !peek ? "Today" : fmtDay(today + offset * DAY_MS);
const nudge = (px: number) => ({ "data-ns-tb-nudge": "", style: { "--ns-tb-nudge": `${px}px` } as React.CSSProperties });
const root = React.useRef<HTMLDivElement>(null);
/* the caps the bar shows run while focus is in the stage or the pointer is on it */
React.useEffect(() => {
const onKey = (e: KeyboardEvent) => {
const el = root.current;
const k = (e.metaKey || e.ctrlKey) && !e.altKey && !e.shiftKey ? ({ b: "bold", i: "italic", u: "underline" } as const)[e.key.toLowerCase() as "b" | "i" | "u"] : undefined;
if (!k || !el || (!el.contains(document.activeElement) && !el.matches(":hover"))) return;
e.preventDefault();
if (!e.repeat) setOn((x) => ({ ...x, [k]: !x[k] }));
};
document.addEventListener("keydown", onKey);
return () => document.removeEventListener("keydown", onKey);
}, []);
const play = useSelfPlay(root, { beats: [400], off: less });
React.useEffect(() => {
if (!play.mine && play.step === 0) pressIn(root.current, '[aria-label="Italic"]');
}, [play.step, play.mine]);
return (
<TooltipProvider>
<div ref={root} onPointerDownCapture={play.handOver} onKeyDownCapture={play.handOver} className="flex w-full justify-center py-10 @container">
<div className="flex flex-wrap items-center justify-center gap-3">
<Toolbar label="Calendar day" variant={variant} onPointerEnter={() => setPeek(true)} onPointerLeave={() => setPeek(false)} onFocus={() => setPeek(true)} onBlur={() => setPeek(false)}>
<IconButton intent="secondary" label="Previous day" onClick={() => setOffset((o) => o - 1)} {...nudge(-2)}>
<ChevronLeft aria-hidden />
</IconButton>
<Button intent="secondary" onClick={() => setOffset(0)}>
<DayLabel words={words} less={less} />
</Button>
<IconButton intent="secondary" label="Next day" onClick={() => setOffset((o) => o + 1)} {...nudge(2)}>
<ChevronRight aria-hidden />
</IconButton>
</Toolbar>
<Toolbar label="Text style" variant={variant}>
<IconButton intent="secondary" label="Bold" shortcut="⌘B" pressed={on.bold} onClick={flip("bold")}>
<Bold aria-hidden />
</IconButton>
<IconButton intent="secondary" label="Italic" shortcut="⌘I" pressed={on.italic} onClick={flip("italic")}>
<Italic aria-hidden />
</IconButton>
<IconButton intent="secondary" label="Underline" shortcut="⌘U" pressed={on.underline} onClick={flip("underline")}>
<Underline aria-hidden />
</IconButton>
</Toolbar>
</div>
</div>
</TooltipProvider>
);
}"use client";
import * as React from "react";
import { Bold, ChevronLeft, ChevronRight, Italic, Underline } from "@/lib/notchset/icons";
import { Button } from "@/components/ui/notchset/button";
import { IconButton } from "@/components/ui/notchset/icon-button";
import { ButtonRoll } from "@/lib/notchset/button-look";
import { useLessMotion } from "@/lib/notchset/motion";
import { Toolbar } from "@/components/ui/notchset/toolbar";
import { TooltipProvider } from "@/components/ui/notchset/tooltip";
import { pressIn, useSelfPlay } from "./self-play";
import { DAY_MS, dayMs, useToday } from "./today";
/*
* The toolbar alone: two joined bars side by side, the calendar's ‹ Today › (hover or focus it for the date; the
* chevrons step the day and roll it in) and the text style's Bold, Italic and Underline, each a toggle that latches by
* sinking and stays sunk until pressed again; ⌘B, ⌘I and ⌘U (Ctrl off a Mac) run them while the hand is on the stage,
* the open tip's cap sinking. Each bar is one tab stop; the arrows (Home, End) walk its buttons. On
* arrival Italic latches once (with less motion, at once); then it is yours. Shown enlarged on a wide stage, true size
* on a phone. `apart` draws the same bars as separate buttons. The bar a selection raises over a list is Bulk bar's.
*/
const DAY = new Intl.DateTimeFormat("en-GB", { weekday: "short", day: "numeric", month: "short", timeZone: "UTC" });
const part = (parts: Intl.DateTimeFormatPart[], t: Intl.DateTimeFormatPartTypes) => parts.find((p) => p.type === t)?.value ?? "";
/** a day as the bar prints it, "Thu 12 Nov", in three parts so the cell can reserve the widest of each */
export const dayParts = (ms: number) => {
const p = DAY.formatToParts(ms);
return [part(p, "weekday"), part(p, "day"), part(p, "month")] as const;
};
export const fmtDay = (ms: number) => dayParts(ms).join(" ");
/* every weekday, day of the month and month the label can show (a 2026 sweep covers them all) */
const Y = Date.UTC(2026, 0, 1);
const every = (i: 0 | 1 | 2, n: number) => [...new Set(Array.from({ length: n }, (_, d) => dayParts(Y + d * 86_400_000)[i]))];
export const SIZES = { weekday: every(0, 7), day: every(1, 31), month: every(2, 365) };
/* the label's box: as wide as the widest label it can show, measured by the type itself (invisible copies of every
weekday, day and month, stacked), so the words change inside a box that never moves */
const stack = (all: string[]) => (
<span className="inline-grid">
{all.map((x) => (
<span key={x} className="[grid-area:1/1]">
{x}
</span>
))}
</span>
);
function DayLabel({ words, less }: { words: string; less: boolean }) {
return (
<span data-slot="toolbar-day" className="inline-grid justify-items-center">
<span aria-hidden data-slot="toolbar-day-sizer" className="invisible whitespace-nowrap [grid-area:1/1]">
{stack(SIZES.weekday)} {stack(SIZES.day)} {stack(SIZES.month)}
</span>
<span aria-hidden className="invisible [grid-area:1/1]">
Today
</span>
<span className="[grid-area:1/1] whitespace-nowrap">
{less ? (
words
) : (
/* the old word rolls out as the new rolls in, inside the reserved box: no clip, no width change */
<ButtonRoll k={words} className="!w-auto">
{words}
</ButtonRoll>
)}
</span>
</span>
);
}
export default function ToolbarDemo() {
const apart = false as boolean;
const less = useLessMotion();
const variant = apart ? "separate" : "joined";
const [offset, setOffset] = React.useState(0);
const [peek, setPeek] = React.useState(false);
const [on, setOn] = React.useState({ bold: true, italic: false, underline: false });
const flip = (k: keyof typeof on) => () => setOn((x) => ({ ...x, [k]: !x[k] }));
const today = dayMs(useToday("2026-11-12"));
const words = offset === 0 && !peek ? "Today" : fmtDay(today + offset * DAY_MS);
const nudge = (px: number) => ({ "data-ns-tb-nudge": "", style: { "--ns-tb-nudge": `${px}px` } as React.CSSProperties });
const root = React.useRef<HTMLDivElement>(null);
/* the caps the bar shows run while focus is in the stage or the pointer is on it */
React.useEffect(() => {
const onKey = (e: KeyboardEvent) => {
const el = root.current;
const k = (e.metaKey || e.ctrlKey) && !e.altKey && !e.shiftKey ? ({ b: "bold", i: "italic", u: "underline" } as const)[e.key.toLowerCase() as "b" | "i" | "u"] : undefined;
if (!k || !el || (!el.contains(document.activeElement) && !el.matches(":hover"))) return;
e.preventDefault();
if (!e.repeat) setOn((x) => ({ ...x, [k]: !x[k] }));
};
document.addEventListener("keydown", onKey);
return () => document.removeEventListener("keydown", onKey);
}, []);
const play = useSelfPlay(root, { beats: [400], off: less });
React.useEffect(() => {
if (!play.mine && play.step === 0) pressIn(root.current, '[aria-label="Italic"]');
}, [play.step, play.mine]);
return (
<TooltipProvider>
<div ref={root} onPointerDownCapture={play.handOver} onKeyDownCapture={play.handOver} className="flex w-full justify-center py-10 @container">
<div className="flex flex-wrap items-center justify-center gap-3">
<Toolbar label="Calendar day" variant={variant} onPointerEnter={() => setPeek(true)} onPointerLeave={() => setPeek(false)} onFocus={() => setPeek(true)} onBlur={() => setPeek(false)}>
<IconButton intent="secondary" label="Previous day" onClick={() => setOffset((o) => o - 1)} {...nudge(-2)}>
<ChevronLeft aria-hidden />
</IconButton>
<Button intent="secondary" onClick={() => setOffset(0)}>
<DayLabel words={words} less={less} />
</Button>
<IconButton intent="secondary" label="Next day" onClick={() => setOffset((o) => o + 1)} {...nudge(2)}>
<ChevronRight aria-hidden />
</IconButton>
</Toolbar>
<Toolbar label="Text style" variant={variant}>
<IconButton intent="secondary" label="Bold" shortcut="⌘B" pressed={on.bold} onClick={flip("bold")}>
<Bold aria-hidden />
</IconButton>
<IconButton intent="secondary" label="Italic" shortcut="⌘I" pressed={on.italic} onClick={flip("italic")}>
<Italic aria-hidden />
</IconButton>
<IconButton intent="secondary" label="Underline" shortcut="⌘U" pressed={on.underline} onClick={flip("underline")}>
<Underline aria-hidden />
</IconButton>
</Toolbar>
</div>
</div>
</TooltipProvider>
);
}"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 };"use client";
import * as React from "react";
/*
* The real today, for every demo that shows a date: a calendar always opens on the latest day. A demo's data is written around its own anchor day; `useDays(anchor)` moves
* every date by the distance from that anchor to the visitor's today, so "in 3 days" stays in 3 days and today is
* the real today.
*
* Hydration: the server and the hydrating pass render each demo at its own anchor (the text in the server's HTML);
* the client then reads its own clock and moves the dates, so nothing differs while hydrating.
*
* The one switch, ANCHOR mode or a pinned day, wins over the clock: `pinToday("anchor" | "YYYY-MM-DD" | null)` in
* code, or `window.__NS_TODAY__` set before the page runs (the visual gate sets "anchor", so its pictures hold:
* scripts/lib/ui-check-cache.mjs). Under vitest (NODE_ENV "test") it is "anchor": every demo reads its own dates.
*/
export const STABLE_TODAY = "2026-11-16";
export const DAY_MS = 86_400_000;
/** the switch's value that holds every demo at the day its data was written around */
export const ANCHOR = "anchor";
let pinned: string | null = null;
/** the switch: "anchor", a day ("YYYY-MM-DD"), or null to follow the clock again */
export function pinToday(day: string | null) {
pinned = day;
}
// read off globalThis: a Vite install has no Node types
const testing = () => (globalThis as { process?: { env?: { NODE_ENV?: string } } }).process?.env?.NODE_ENV === "test";
function frozen(): string | null {
const w = (globalThis as { __NS_TODAY__?: unknown }).__NS_TODAY__;
return pinned ?? (typeof w === "string" ? w : null) ?? (testing() ? ANCHOR : null);
}
const pad = (n: number) => String(n).padStart(2, "0");
/** the visitor's today in their own zone, as "YYYY-MM-DD" (or ANCHOR when the switch holds the demos still) */
export function readToday(): string {
const f = frozen();
if (f) return f;
const d = new Date();
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;
}
/* a day key to its UTC midnight, and back */
export const dayMs = (day: string) => Date.UTC(+day.slice(0, 4), +day.slice(5, 7) - 1, +day.slice(8, 10));
export const dayKey = (ms: number) => new Date(ms).toISOString().slice(0, 10);
/** whole days from a to b */
export const daysBetween = (a: string, b: string) => Math.round((dayMs(b) - dayMs(a)) / DAY_MS);
/* a check once a minute catches midnight (none while the switch holds the day) */
const subscribe = (f: () => void) => {
if (frozen()) return () => {};
const t = setInterval(f, 60_000);
return () => clearInterval(t);
};
const serverToday = () => ANCHOR;
/* "YYYY-MM-DD", or ANCHOR on the server, while hydrating and under the switch */
const useClockDay = () => React.useSyncExternalStore(subscribe, readToday, serverToday);
/** today as "YYYY-MM-DD", for a demo with no dates of its own: `anchor` on the server, while hydrating and under
* the switch, then the visitor's own */
export function useToday(anchor = STABLE_TODAY): string {
const day = useClockDay();
return day === ANCHOR ? anchor : day;
}
export type Days = {
/** today, "YYYY-MM-DD" */
today: string;
/** today's UTC midnight */
todayMs: number;
/** days the anchor moved */
delta: number;
/** a "YYYY-MM-DD" (or a longer ISO stamp; its time is kept) written around the anchor, moved to the real today */
day: (iso: string) => string;
/** a moment written around the anchor (ms), moved by whole days */
ms: (at: number) => number;
};
export function shiftBy(today: string, anchor: string, weeks = false): Days {
const raw = daysBetween(anchor, today);
/* `weeks`: move by whole weeks so every date keeps its weekday (a week of meetings stays Monday to Friday): the
anchor's Monday-to-Sunday week lands on today's */
const delta = weeks ? Math.floor((raw + ((new Date(dayMs(anchor)).getUTCDay() + 6) % 7)) / 7) * 7 : raw;
return {
today,
todayMs: dayMs(today),
delta,
day: (iso) => (/^\d{4}-\d\d-\d\d/.test(iso) ? dayKey(dayMs(iso) + delta * DAY_MS) + iso.slice(10) : iso),
ms: (at) => at + delta * DAY_MS,
};
}
/** dates written around `anchor` (the demo's own today), moved so the anchor lands on the real today */
export function useDays(anchor: string, opts: { weeks?: boolean } = {}): Days {
const today = useToday(anchor);
const weeks = !!opts.weeks;
return React.useMemo(() => shiftBy(today, anchor, weeks), [today, anchor, weeks]);
}
/* the US public holidays of a year, as "YYYY-MM-DD" */
function holidaysOf(y: number): { day: string; name: string }[] {
const nth = (m: number, weekday: number, n: number) => {
const first = new Date(Date.UTC(y, m, 1)).getUTCDay();
return Date.UTC(y, m, 1 + ((weekday - first + 7) % 7) + (n - 1) * 7);
};
const last = (m: number, weekday: number) => {
const end = Date.UTC(y, m + 1, 0);
return end - ((new Date(end).getUTCDay() - weekday + 7) % 7) * DAY_MS;
};
return [
{ day: Date.UTC(y, 0, 1), name: "New Year's Day" },
{ day: nth(0, 1, 3), name: "Martin Luther King Jr. Day" },
{ day: nth(1, 1, 3), name: "Presidents' Day" },
{ day: last(4, 1), name: "Memorial Day" },
{ day: Date.UTC(y, 5, 19), name: "Juneteenth" },
{ day: Date.UTC(y, 6, 4), name: "Independence Day" },
{ day: nth(8, 1, 1), name: "Labor Day" },
{ day: nth(9, 1, 2), name: "Columbus Day" },
{ day: Date.UTC(y, 10, 11), name: "Veterans Day" },
{ day: nth(10, 4, 4), name: "Thanksgiving Day" },
{ day: Date.UTC(y, 11, 25), name: "Christmas Day" },
].map((h) => ({ day: dayKey(h.day), name: h.name }));
}
/** the US public holidays from one day to another, both kept */
export function usHolidays(from: string, to: string): { day: string; name: string }[] {
const out: { day: string; name: string }[] = [];
for (let y = +from.slice(0, 4); y <= +to.slice(0, 4); y++) out.push(...holidaysOf(y).filter((h) => h.day >= from && h.day <= to));
return out;
}
/** the report periods round a day: this quarter, last quarter, this year, the last 30 days */
export function periodsAround(today: string) {
const y = +today.slice(0, 4);
const q = Math.floor((+today.slice(5, 7) - 1) / 3);
const quarter = (y: number, q: number) => ({ start: `${y}-${pad(q * 3 + 1)}-01`, end: dayKey(Date.UTC(y, q * 3 + 3, 0)) });
const last = q === 0 ? quarter(y - 1, 3) : quarter(y, q - 1);
return [
{ label: "This quarter", ...quarter(y, q) },
{ label: "Last quarter", ...last },
{ label: "This year", start: `${y}-01-01`, end: `${y}-12-31` },
{ label: "Last 30 days", start: dayKey(dayMs(today) - 29 * DAY_MS), end: today },
];
}
/** a month's close dates: each "YYYY-MM-DD" keeps its day of the month in `month` ("YYYY-MM"), the last day at most */
export function inMonth(month: string, iso: string): string {
const last = new Date(Date.UTC(+month.slice(0, 4), +month.slice(5, 7), 0)).getUTCDate();
return `${month}-${pad(Math.min(+iso.slice(8, 10), last))}`;
}This example also uses Button, Icon button. This command installs them with it, so the example pastes as it is:
pnpm dlx shadcn@latest add https://notchset.dev/r/toolbar.json https://notchset.dev/r/button.json https://notchset.dev/r/icon-button.jsoncomponents/ui/notchset/toolbar.tsx
LevelMolecule: made of atoms only.
Made ofKeyboard hint,Tooltip
Free, no account or key. One command for every shadcn style. With the @notchset registry added, @notchset/<name> works too.
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.
label–
stringNames the toolbar for screen readers ("Selected deals").
orientation"horizontal"
"horizontal" | "vertical"horizontal (the default) moves with ← →; vertical with ↑ ↓
variant"separate"
"separate" | "joined"separate (the default): each button keeps its own shape; joined: one capsule, its buttons attached on hairlines
Three usesa selection's bulk actions in a floating bar · a note's formatting bar · a strip of live readings walked with the arrows (useRovingFocus)
Give your coding assistant the Markdown guide instead of screenshots.
https://notchset.dev/api/mcp (setup)v1.1.0 · 2026-11-17
Ships key-cap-parts.tsx (KEY_CAP_LABELS, KeyCaps, asCtrl, capsOf, hintProps, isApple, keyCap, keyCapTone, KeyCapLabels, KeyCapsProps, Shortcut), which it now uses. toolbar.tsx now exports ToolbarKey, ToolbarKeyProps.
v1.0.0 · 2026-11-09
Released free with the Notchset system.