# Onboarding Checklist

> A setup checklist with native completion controls, expandable steps, and an updating progress count.

- Kind: ui · Category: Feedback · Interactivity: script
- Install: `npx shadcn@latest add @haze/onboarding-checklist`
- File: `src/components/haze/ui/onboarding-checklist.astro`
- npm dependencies: @lucide/astro
- Registry dependencies: @haze/utils
- Docs page: https://hazeui.com/ui/onboarding-checklist

## Use when
- Workspace setup has a handful of independently completable steps.
- Each step needs short instructions without leaving the checklist.

## Avoid when
- Steps must run in a strict sequence. Use stepper.

## Alternatives
- [stepper](https://hazeui.com/ui/stepper.md)
- [checkbox-group](https://hazeui.com/ui/checkbox-group.md)
- [progress](https://hazeui.com/ui/progress.md)

## Props

| Name | Type | Default | Required | Description |
|---|---|---|---|---|
| id | `string` |  | yes | Unique heading prefix and default input group name. |
| title | `string` |  | no | Checklist title. |
| name | `string` |  | no | Shared checkbox form name. |
| items | `{ id: string; title: string; detail?: string; href?: string; done?: boolean }[]` |  | no | Step content, destinations and initial completion. |
| class | `string` |  | no | Additional classes on the component wrapper. |

## 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.
- Key Space: Check a focused setup step.
- Key Enter / Space: Expand its instructions.

## Agent prompts

### 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": "https://hazeui.com/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: https://hazeui.com/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.

## Example requests that should lead here
- Track team setup with a live completion count and expandable instructions per step.

## Source

```astro
---
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>
```
