{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "steps",
  "type": "registry:ui",
  "title": "Steps",
  "description": "A rail that shows where one is in a sequence of steps: a row of thin segments, or numbered markers with titles, each step with a state (done, filled in for you, current, not started, skipped, blocked).",
  "categories": [
    "ui"
  ],
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [
    "@rivier-ui/theme",
    "@rivier-ui/cn"
  ],
  "files": [
    {
      "path": "registry/ui/steps.tsx",
      "type": "registry:ui",
      "target": "components/ui/steps.tsx",
      "content": "\"use client\";\n/**\n * @name steps\n * @category ui\n * @description A rail that shows where one is in a sequence of steps: a row of thin segments, or numbered markers with titles, each step with a state (done, filled in for you, current, not started, skipped, blocked).\n * @when Showing progress through a known, ordered set of steps: a booking, a sign-up, an import, a checklist that runs in order. Use \"segments\" above a card where space is short and \"labelled\" where the step names help. Pair it with StepsCount (\"Step 2 of 5\"), which says the same in words. For a measured amount of one task use progress; for the whole guided task with its buttons use wizard, which draws this rail itself; for moving between unordered views use tabs.\n * @example\n * <StepsCount current={2} total={4} />\n * <Steps aria-label=\"Booking progress\">\n *   <Step state=\"done\">Dates</Step>\n *   <Step state=\"current\">People</Step>\n *   <Step state=\"upcoming\">Extras</Step>\n *   <Step state=\"upcoming\">Review</Step>\n * </Steps>\n *\n * // Numbered markers with titles; a finished step can be a button that goes back to it\n * <Steps variant=\"labelled\" aria-label=\"Import\">\n *   <Step state=\"done\" onClick={() => goTo(\"file\")}>Choose a file</Step>\n *   <Step state=\"assumed\" note=\"Taken from the file's first row\">Match the columns</Step>\n *   <Step state=\"current\" description=\"About a minute\">Check the rows</Step>\n *   <Step state=\"skipped\">Add notes</Step>\n * </Steps>\n */\nimport { Ban, Check, Minus } from \"lucide-react\";\nimport { createContext, use, type ComponentProps, type MouseEventHandler, type ReactNode } from \"react\";\nimport { cn } from \"@/lib/cn\";\n\nexport type StepState = \"done\" | \"assumed\" | \"current\" | \"upcoming\" | \"skipped\" | \"blocked\";\nexport type StepsVariant = \"segments\" | \"labelled\";\n\n/** The word said (and, in the labelled variant, shown where it matters) for each state. Translate them with the interface. */\nexport const STEP_STATE_LABELS: Record<StepState, string> = {\n  done: \"Done\",\n  assumed: \"Filled in for you\",\n  current: \"Current step\",\n  upcoming: \"Not started\",\n  skipped: \"Skipped\",\n  blocked: \"Blocked\",\n};\n\nconst StepsContext = createContext<{ variant: StepsVariant; stateLabels: Record<StepState, string> }>({ variant: \"segments\", stateLabels: STEP_STATE_LABELS });\n\nexport type StepsProps = ComponentProps<\"ol\"> & {\n  /** \"segments\" (default): one thin segment per step. \"labelled\": numbered markers with titles, in a column that becomes a row when the rail is wide enough. */\n  variant?: StepsVariant;\n  /** The word for each state, where the English defaults are not wanted. */\n  stateLabels?: Partial<Record<StepState, string>>;\n};\n\n/**\n * An ordered list, so a screen reader says how many steps there are and which one it is on. Name it with\n * `aria-label` or `aria-labelledby`. Every step is read as its title and its state in words; the marks\n * (tick, ring, dashes, bar) repeat the state for the eye, so it never rests on colour alone.\n */\nexport function Steps({ className, variant = \"segments\", stateLabels, children, ...props }: StepsProps) {\n  return (\n    <div data-slot=\"steps\" data-variant={variant} className={cn(\"@container w-full min-w-0\", className)}>\n      <ol\n        data-slot=\"steps-list\"\n        className={cn(\"[counter-reset:rui-step]\", variant === \"segments\" ? \"flex w-full items-center gap-1.5\" : \"flex w-full flex-col @lg:flex-row @lg:gap-3\")}\n        {...props}\n      >\n        <StepsContext value={{ variant, stateLabels: { ...STEP_STATE_LABELS, ...stateLabels } }}>{children}</StepsContext>\n      </ol>\n    </div>\n  );\n}\n\nexport type StepProps = Omit<ComponentProps<\"li\">, \"onClick\"> & {\n  state: StepState;\n  /** Why the step is in this state: what was filled in and from where, or what is in the way. Read out with the state; shown under the title in the labelled variant. */\n  note?: string;\n  /** A line under the title in the labelled variant. */\n  description?: ReactNode;\n  /** Makes the step a button, for a step the person may go back to. */\n  onClick?: MouseEventHandler<HTMLButtonElement>;\n  /** Makes the step a link. */\n  href?: string;\n};\n\nconst SEGMENT: Record<StepState, string> = {\n  done: \"bg-primary\",\n  assumed: \"bg-primary\",\n  current: \"h-1.5 bg-foreground\",\n  upcoming: \"bg-input\",\n  // Dashes: drawn as short pieces (see Step), so they stay dashes at any width.\n  skipped: \"flex h-0.5 gap-1 bg-transparent\",\n  blocked: \"bg-destructive\",\n};\n\nconst MARKER: Record<StepState, string> = {\n  done: \"border-primary bg-primary text-primary-foreground\",\n  assumed: \"border-primary bg-highlight-soft text-foreground\",\n  current: \"border-2 border-foreground bg-background font-medium text-foreground\",\n  upcoming: \"border-input bg-background text-muted-foreground\",\n  skipped: \"border-dashed border-input bg-background text-muted-foreground\",\n  blocked: \"border-destructive bg-background text-destructive\",\n};\n\n/** The mark inside a labelled marker: an icon for the states that have one, the step's number for the rest. */\nfunction MarkerContent({ state }: { state: StepState }) {\n  if (state === \"done\") return <Check aria-hidden=\"true\" strokeWidth={2} className=\"size-4\" />;\n  if (state === \"skipped\") return <Minus aria-hidden=\"true\" strokeWidth={2} className=\"size-4\" />;\n  if (state === \"blocked\") return <Ban aria-hidden=\"true\" strokeWidth={2} className=\"size-4\" />;\n  return <span aria-hidden=\"true\" className=\"tabular-nums before:content-[counter(rui-step)]\" />;\n}\n\n/**\n * One step. Its children are its title. In the segments variant the title and state are read out but not\n * shown; in the labelled variant they are shown. The current step carries `aria-current=\"step\"`.\n */\nexport function Step({ className, state, note, description, onClick, href, children, ...props }: StepProps) {\n  const { variant, stateLabels } = use(StepsContext);\n  const stateText = `${stateLabels[state]}${note ? `: ${note}` : \"\"}`;\n  const interactive = \"rounded-control transition-opacity duration-instant ease-out hover:opacity-80 motion-reduce:transition-none\";\n\n  if (variant === \"segments\") {\n    const body = (\n      <>\n        <span aria-hidden=\"true\" data-slot=\"step-segment\" className={cn(\"block h-1 w-full rounded-full\", SEGMENT[state])}>\n          {state === \"skipped\" ? Array.from({ length: 4 }, (_, piece) => <span key={piece} className=\"h-full flex-1 rounded-full bg-input\" />) : null}\n        </span>\n        {state === \"assumed\" || state === \"blocked\" ? (\n          // A second mark on the bar: an open ring for \"filled in for you\", a filled square for \"blocked\".\n          <span\n            aria-hidden=\"true\"\n            data-slot=\"step-mark\"\n            className={cn(\"absolute end-0 top-1/2 size-2.5 -translate-y-1/2 border-2\", state === \"assumed\" ? \"rounded-full border-primary bg-background\" : \"rounded-none border-destructive bg-destructive\")}\n          />\n        ) : null}\n        <span className=\"sr-only\">\n          {children}, {stateText}\n        </span>\n      </>\n    );\n    // The bar is thin; the pressable area around it is 24px tall, 40px on touch screens.\n    const hit = \"relative flex h-6 w-full items-center pointer-coarse:h-10\";\n    return (\n      <li data-slot=\"step\" data-state={state} aria-current={state === \"current\" ? \"step\" : undefined} title={note} className={cn(\"relative min-w-0 flex-1 [counter-increment:rui-step]\", className)} {...props}>\n        {href !== undefined ? (\n          <a href={href} className={cn(hit, interactive)}>\n            {body}\n          </a>\n        ) : onClick ? (\n          <button type=\"button\" onClick={onClick} className={cn(hit, interactive)}>\n            {body}\n          </button>\n        ) : (\n          <span className={hit}>{body}</span>\n        )}\n      </li>\n    );\n  }\n\n  const body = (\n    <>\n      <span data-slot=\"step-marker\" className={cn(\"relative z-[1] inline-flex size-7 shrink-0 items-center justify-center rounded-full border text-xs\", MARKER[state])}>\n        <MarkerContent state={state} />\n      </span>\n      <span className=\"flex min-w-0 flex-col gap-0.5 pt-1 text-start @lg:pt-0\">\n        <span data-slot=\"step-title\" className={cn(\"text-sm leading-tight\", state === \"current\" ? \"font-medium text-foreground\" : state === \"upcoming\" || state === \"skipped\" ? \"text-muted-foreground\" : \"text-foreground\")}>\n          {children}\n        </span>\n        {/* The state in words. Shown where the marker alone could be misread; always read out. */}\n        <span data-slot=\"step-state\" className={cn(\"text-xs text-muted-foreground\", state === \"done\" || state === \"current\" || state === \"upcoming\" ? (note ? \"\" : \"sr-only\") : \"\")}>\n          {stateText}\n        </span>\n        {description ? (\n          <span data-slot=\"step-description\" className=\"text-xs text-muted-foreground\">\n            {description}\n          </span>\n        ) : null}\n      </span>\n    </>\n  );\n  const row = \"flex w-full min-w-0 gap-3 @lg:flex-col @lg:gap-2\";\n  return (\n    <li\n      data-slot=\"step\"\n      data-state={state}\n      aria-current={state === \"current\" ? \"step\" : undefined}\n      className={cn(\n        \"relative min-w-0 pb-5 [counter-increment:rui-step] last:pb-0 @lg:flex-1 @lg:pb-0\",\n        // The line to the next step: down the column, or along the row.\n        \"before:absolute before:start-[calc(0.875rem-0.5px)] before:top-8 before:bottom-1 before:w-px before:bg-border-strong last:before:hidden\",\n        \"@lg:before:start-9 @lg:before:end-0 @lg:before:top-[calc(0.875rem-0.5px)] @lg:before:bottom-auto @lg:before:h-px @lg:before:w-auto\",\n        className,\n      )}\n      {...props}\n    >\n      {href !== undefined ? (\n        <a href={href} className={cn(row, interactive)}>\n          {body}\n        </a>\n      ) : onClick ? (\n        <button type=\"button\" onClick={onClick} className={cn(row, interactive)}>\n          {body}\n        </button>\n      ) : (\n        <span className={row}>{body}</span>\n      )}\n    </li>\n  );\n}\n\nexport type StepsCountProps = ComponentProps<\"p\"> & {\n  /** The step one is on, counted from 1. */\n  current: number;\n  total: number;\n  /** The words. Default: \"Step 2 of 5\". Translate it with the interface. */\n  label?: (current: number, total: number) => string;\n};\n\n/** The count in words: what the rail shows, for everyone. */\nexport function StepsCount({ className, current, total, label = (now, all) => `Step ${now} of ${all}`, ...props }: StepsCountProps) {\n  return (\n    <p data-slot=\"steps-count\" className={cn(\"text-xs text-muted-foreground tabular-nums\", className)} {...props}>\n      {label(current, total)}\n    </p>\n  );\n}\n"
    }
  ],
  "meta": {
    "category": "ui",
    "when": "Showing progress through a known, ordered set of steps: a booking, a sign-up, an import, a checklist that runs in order. Use \"segments\" above a card where space is short and \"labelled\" where the step names help. Pair it with StepsCount (\"Step 2 of 5\"), which says the same in words. For a measured amount of one task use progress; for the whole guided task with its buttons use wizard, which draws this rail itself; for moving between unordered views use tabs.",
    "example": "<StepsCount current={2} total={4} />\n<Steps aria-label=\"Booking progress\">\n  <Step state=\"done\">Dates</Step>\n  <Step state=\"current\">People</Step>\n  <Step state=\"upcoming\">Extras</Step>\n  <Step state=\"upcoming\">Review</Step>\n</Steps>\n\n// Numbered markers with titles; a finished step can be a button that goes back to it\n<Steps variant=\"labelled\" aria-label=\"Import\">\n  <Step state=\"done\" onClick={() => goTo(\"file\")}>Choose a file</Step>\n  <Step state=\"assumed\" note=\"Taken from the file's first row\">Match the columns</Step>\n  <Step state=\"current\" description=\"About a minute\">Check the rows</Step>\n  <Step state=\"skipped\">Add notes</Step>\n</Steps>",
    "client": true
  }
}
