Onboarding Checklist
A setup checklist with native completion controls, expandable steps, and an updating progress count.
pnpm dlx shadcn@latest add @haze/onboarding-checklist---
import { Check, ChevronDown } from "@lucide/astro";
import { cn } from "../../../lib/haze/utils";
interface Props {
id: string;
title?: string;
name?: string;
items?: { id: string; title: string; detail?: string; href?: string; done?: boolean }[];
class?: string;
}
const { id, title = "Set up your workspace", name = id, class: className, items = [
{ id: "profile", title: "Add your profile", detail: "Choose the name your team will see.", done: true },
{ id: "invite", title: "Invite your team", detail: "Bring your reviewers into one workspace." },
{ id: "review", title: "Create a review", detail: "Add a draft to collect feedback." },
] } = Astro.props;
const completed = items.filter(item => item.done).length;
---
<section data-haze-onboarding-checklist aria-labelledby={`${id}-title`} class={cn("grid min-w-0 gap-3 rounded-xl border border-border bg-card p-4.5", className)}>
<div class="flex min-w-0 items-start justify-between gap-3">
<p id={`${id}-title`} class="text-[1.0625rem] leading-[1.4] font-medium tracking-[-0.01em]">{title}</p>
<span data-onboarding-count aria-hidden="true" class="shrink-0 font-mono text-xs/5 text-muted-foreground">{completed}/{items.length}</span>
</div>
<progress data-onboarding-progress aria-label="Workspace setup" max={Math.max(1, items.length)} value={completed} class="h-1.5 w-full overflow-hidden rounded-full accent-primary [&::-webkit-progress-bar]:rounded-full [&::-webkit-progress-bar]:bg-muted [&::-webkit-progress-value]:rounded-full [&::-webkit-progress-value]:bg-primary [&::-webkit-progress-value]:transition-[width] [&::-webkit-progress-value]:duration-300 [&::-webkit-progress-value]:ease-snappy [&::-moz-progress-bar]:bg-primary [&::-moz-progress-bar]:transition-[width] [&::-moz-progress-bar]:duration-300 [&::-moz-progress-bar]:ease-snappy motion-reduce:[&::-webkit-progress-value]:transition-none motion-reduce:[&::-moz-progress-bar]:transition-none"></progress>
<ul class="grid min-w-0 gap-2">
{items.map(item => <li class="group/task grid min-w-0 grid-cols-[1.5rem_minmax(0,1fr)] items-start gap-2 rounded-lg border border-border p-2.5 hover:border-border-strong motion-safe:transition-[border-color] motion-safe:duration-150 motion-safe:ease-snappy">
<label class="relative grid size-6 cursor-pointer place-items-center rounded-full">
<input type="checkbox" name={name} value={item.id} checked={item.done} aria-label={`Complete ${item.title}`} class="peer size-5 cursor-pointer appearance-none rounded-full border border-border-strong bg-field hover:border-foreground/50 checked:border-primary checked:bg-primary motion-safe:transition-[border-color,background-color] motion-safe:duration-150 motion-safe:ease-snappy focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring forced-colors:appearance-auto" />
<Check aria-hidden="true" class="pointer-events-none absolute size-3 scale-50 text-primary-foreground opacity-0 motion-safe:transition-[scale,opacity] motion-safe:duration-200 motion-safe:ease-spring peer-checked:scale-100 peer-checked:opacity-100" />
</label>
<details class="group/disclosure min-w-0 [interpolate-size:allow-keywords] [&::details-content]:h-0 [&::details-content]:overflow-hidden [&::details-content]:transition-[height,content-visibility] [&::details-content]:transition-discrete [&::details-content]:duration-300 [&::details-content]:ease-snappy [&[open]::details-content]:h-auto">
<summary class="flex min-h-6 cursor-pointer list-none items-center justify-between gap-2 rounded-sm text-[0.8125rem]/5 font-medium wrap-anywhere focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring [&::-webkit-details-marker]:hidden">
{item.title}<ChevronDown aria-hidden="true" class="size-3 shrink-0 motion-safe:transition-[rotate] motion-safe:duration-200 motion-safe:ease-snappy group-open/disclosure:rotate-180" />
</summary>
<p class="py-2 text-xs/5 text-muted-foreground">{item.detail} {item.href && <a href={item.href} class="rounded-sm text-foreground underline underline-offset-4 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring">Open step</a>}</p>
</details>
</li>)}
</ul>
<p data-onboarding-status role="status" class="text-xs/5 text-muted-foreground">{completed} of {items.length} steps complete</p>
</section>
<script>
const reduced = matchMedia("(prefers-reduced-motion: reduce)");
// Digit roll (NumberFlow behaviour): only characters that changed move, up when the value rises, down when it falls.
const roll = (el: HTMLElement, next: string, direction: number) => {
const before = Array.from(el.dataset.rolled ?? el.textContent ?? "");
el.dataset.rolled = next;
el.replaceChildren();
if (reduced.matches) { el.textContent = next; return; }
const easing = getComputedStyle(el).getPropertyValue("--ease-snappy").trim() || "ease";
const after = Array.from(next);
after.forEach((character, index) => {
const previous = before[before.length - after.length + index];
const column = document.createElement("span");
column.className = "relative inline-grid overflow-hidden align-bottom whitespace-pre";
const digit = document.createElement("span");
digit.textContent = character;
column.append(digit);
el.append(column);
if (previous === character) return;
const shift = /\p{Nd}/u.test(character) ? 100 : 30;
digit.animate([{ opacity: 0, translate: `0 ${direction * shift}%` }, { opacity: 1, translate: "0 0" }], { duration: 250, easing });
if (previous === undefined) return;
const ghost = document.createElement("span");
ghost.className = "absolute inset-0";
ghost.textContent = previous;
column.append(ghost);
const out = ghost.animate([{ opacity: 1, translate: "0 0" }, { opacity: 0, translate: `0 ${-direction * shift}%` }], { duration: 250, easing });
out.finished.then(() => ghost.remove(), () => ghost.remove());
});
};
function enhance(root: HTMLElement) {
if (root.hasAttribute("data-enhanced")) return;
const boxes = [...root.querySelectorAll<HTMLInputElement>("input[type=checkbox]")];
const progress = root.querySelector<HTMLProgressElement>("progress")!;
const count = root.querySelector<HTMLElement>("[data-onboarding-count]")!;
const status = root.querySelector<HTMLElement>("[data-onboarding-status]")!;
const sync = () => {
const checked = boxes.filter(box => box.checked);
progress.value = checked.length;
const label = `${checked.length}/${boxes.length}`;
const previous = Number((count.dataset.rolled ?? count.textContent ?? "").split("/")[0]);
if (label !== (count.dataset.rolled ?? count.textContent)) roll(count, label, checked.length >= previous ? 1 : -1);
status.textContent = checked.length === boxes.length && boxes.length > 0 ? "Workspace setup complete." : `${checked.length} of ${boxes.length} steps complete`;
root.dispatchEvent(new CustomEvent("haze:onboarding-change", { bubbles: true, detail: { completed: checked.map(box => box.value) } }));
};
root.addEventListener("change", sync);
boxes[0]?.form?.addEventListener("reset", () => queueMicrotask(sync));
root.setAttribute("data-enhanced", "");
}
const init = () => document.querySelectorAll<HTMLElement>("[data-haze-onboarding-checklist]").forEach(enhance);
init();
if (!document.documentElement.hasAttribute("data-haze-onboarding-checklist-listener")) {
document.documentElement.setAttribute("data-haze-onboarding-checklist-listener", "");
document.addEventListener("astro:page-load", init);
}
</script>When to use
- Workspace setup has a handful of independently completable steps.
- Each step needs short instructions without leaving the checklist.
When not to use
- Steps must run in a strict sequence. Use stepper.
Installation
Add the Haze registry to components.json once, then install Onboarding Checklist with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.
pnpm dlx shadcn@latest add @haze/onboarding-checklistnpx shadcn@latest add @haze/onboarding-checklistyarn dlx shadcn@latest add @haze/onboarding-checklistbunx --bun shadcn@latest add @haze/onboarding-checklistFirst time? Registry and theme setup
1. Add to components.json:
{
"registries": {
"@haze": "http://localhost:4329/r/{name}.json"
}
}2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
| id* | string | – | Unique heading prefix and default input group name. |
| title | string | – | Checklist title. |
| name | string | – | Shared checkbox form name. |
| items | { id: string; title: string; detail?: string; href?: string; done?: boolean }[] | – | Step content, destinations and initial completion. |
| class | string | – | Additional classes on the component wrapper. |
Keyboard interactions
- Space
- Check a focused setup step.
- EnterSpace
- Expand its instructions.
Accessibility
- Each native checkbox names its step. The progress element exposes completion numerically and a status line announces the total.
- Input values submit with the owning form. haze:onboarding-change exposes completed IDs for persistence, while native disclosures keep instructions readable without scripts.
Notes for AI
Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.
Install and use
Install the Haze UI component "Onboarding Checklist" with `npx shadcn@latest add @haze/onboarding-checklist`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import OnboardingChecklist from "@/components/haze/ui/onboarding-checklist.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/ui/onboarding-checklist.md
Customize with real content
Adapt the Haze onboarding-checklist ui for our product. Replace the demo values of these props with our real content: id, title, name, items, class. Keep the layout, the heading level rules and these accessibility details: Each native checkbox names its step. The progress element exposes completion numerically and a status line announces the total. Input values submit with the owning form. haze:onboarding-change exposes completed IDs for persistence, while native disclosures keep instructions readable without scripts. Do not add raw color classes; use the Haze tokens.
Choose the right block
Before using onboarding-checklist, check it fits: use it when workspace setup has a handful of independently completable steps.; each step needs short instructions without leaving the checklist.. Avoid it when steps must run in a strict sequence. use stepper.. Alternatives: @haze/stepper, @haze/checkbox-group, @haze/progress.
Dependencies
- npm: @lucide/astro
- @haze/utils
- @haze/theme (one-time setup)
Source · Original Haze UI work.