# Steps

A multi-step flow shown as numbered markers: done, current and to do.

A multi-step flow shown as numbered markers joined by a rail: done, current, to do. The model is the task rows: the 24px badge column, the completed mark (green, white check), the 1px rail in the line colour, 10.5px/600 step figures. Horizontal (markers in a row of equal columns, each step's text under its marker, a rail between them) or vertical (the rail runs down the marker column, as the task rows' details). Each step may have a panel; Back and Next are real Buttons. Behaviour and ARIA from the Zag steps machine through Ark UI.

Kind: component · Category: Navigation · Status: beta · Targets: React, Vue, Svelte · Behaviour: Zag `steps` machine, through Ark UI

## Add

```bash
npx fndn add steps
```

It writes the folder `steps/` into the project's ui folder (`index.ts`, `steps.tsx`, `Steps.vue`, `Steps.svelte`, `steps.recipe.ts`), and what it is built from: [Button](/components/button.md). First time: [Installation](/installation.md).

## Usage

```tsx
import { Steps } from "@/components/ui/steps";
```

```vue
import { Steps } from "@/components/ui/steps";
```

```svelte
import { Steps } from "$lib/components/ui/steps";
```

## Parts

In the DOM the root carries `data-slot="steps"` and each part `data-slot="steps-<part>"`; in the recipe the root is the `base` slot and each part a slot named after it in camelCase.

| Part | Element | data-slot | Flags | Notes |
| --- | --- | --- | --- | --- |
| `root` | `div` | `steps` |  | Ark's steps root (data-orientation, --percent): a column, the list then the panels then the controls, 16px apart. |
| `list` | `div` | `steps-list` |  | role=tablist (aria-orientation). Horizontal: a row of equal columns. Vertical: a column. |
| `item` | `div` | `steps-item` |  | One step (data-complete, data-current, data-incomplete). Horizontal: an equal share of the row; the trigger (marker, then the text under it) and the rail. Vertical: the trigger, the rail under the marker, 20px to the next step. |
| `trigger` | `button` | `steps-trigger` |  | role=tab, aria-selected and aria-current=step on the current one: the marker and the step's text. Bleeds 6px so the marker lines up with the edge; control radius; hover fills hover (fine pointer), press hover-2 (a row's press), focus ring. linear: not pressable (no hover, no press) and only the current step is in the tab order. |
| `indicator` | `div` | `steps-indicator` |  | The 24px round marker (aria-hidden). To do: 1px line-strong ring, ink-2 figure. Current: ink fill, on-ink figure. Done: the task rows' mark, green fill and a 13px white check. |
| `number` | `span` | `steps-number` |  | The step's figure, 10.5px/600 tabular, as the task rows' step; gives way to the check when done. |
| `check` | `span` | `steps-check` |  | The done check (ph check, bold); arrives scaled from 0.5 with its opacity when the step is done, as the task rows' mark. |
| `text` | `span` | `steps-text` |  | The title and the description, stacked; horizontal: under the marker, 6px apart; vertical: beside it, its first line sharing the marker's 24px line. |
| `title` | `span` | `steps-title` |  | 13px/500 on the body leading; vertical: its first line 24px tall (the marker's line): ink-2 to do, ink when current or done. Wraps, never cut. Author text keeps its own direction. |
| `description` | `span` | `steps-description` | optional | 12px ink-2 under the title; wraps. |
| `separator` | `div` | `steps-separator` |  | The rail (between this step and the next; none after the last): 1px in the line colour, green once this step is done. Horizontal: from 6px after this marker to 6px before the next one, at the markers' middle. Vertical: down the marker column from 4px under the marker to 4px above the next one. |
| `content` | `div` | `steps-content` | optional | role=tabpanel labelled by its trigger: the current step's panel (the others hidden), 13px ink-2; focusable (tabindex 0). |
| `completed` | `div` | `steps-completed` | optional | What shows in place of the panels once every step is done (Next pressed on the last step). |
| `footer` | `div` | `steps-footer` | optional | Back and Next: real Buttons (Back outline, Next primary, size sm), at the end, 8px apart, marked data-steps="prev" / "next"; disabled where there is no step to go to. |

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `items` | `array` |  | The steps in order: { title, description?, content? } (React: nodes; content is the step's panel). |
| `step` | `number` | `0` | Bindable (React: `defaultStep` and `onStepChange`; Vue: `v-model:step`; Svelte: `bind:step`). The current step, from 0; the number of steps means every step is done. React: step / defaultStep / onStepChange. |
| `orientation` | `"horizontal" \| "vertical"` | `"horizontal"` |  |
| `linear` | `boolean` | `false` | The steps are taken in order: only Back and Next move; the markers are not pressable. |
| `controls` | `boolean` | `false` | Show the Back and Next buttons under the panels. |
| `prevLabel` | `string` | `"Back"` |  |
| `nextLabel` | `string` | `"Next"` |  |
| `completed` | `string` |  | What shows once every step is done (React: a node). |

Other attributes and `class` go to the root; `class` is merged through the recipe.

## Events

| Event | Payload |
| --- | --- |
| `stepChange` | (step: number) after a marker, Back or Next is pressed |

## States

`hover`, `press`, `focus-visible`, `current`, `complete`, `incomplete`

## Keyboard and accessibility

Role: tablist (tab, tabpanel).

Keyboard:

- Tab reaches each marker in turn (linear: only the current one), then the current panel, then Back and Next
- Enter / Space on a marker makes it the current step (not linear); the change is instant
- Back / Next are buttons; a disabled one is skipped

Notes:

- The current marker carries aria-selected=true and aria-current=step; its panel is labelled by it.
- A marker's name is its title and description; the figure and the check are hidden from assistive technology.

## Motion

- marker and rail colours over duration.base when a step changes (instant from the keyboard: kbd-instant)
- check: scale 0.5 -> 1 with opacity over duration.press easing.out-strong and duration.base when a step is done (as the task rows' mark); the figure fades out under it. Undone (Back, an earlier marker): shorter and simpler, the check fades over duration.fast and its scale resets after the fade
- reduced motion: the check does not scale, it fades both ways
- trigger hover and press fills over duration.fast (hover gated to a fine pointer)
- panels swap at once (no transition between steps' content)
- first paint: nothing plays

## Tokens

`color.line`, `color.line-strong`, `color.ink`, `color.ink-2`, `color.on-ink`, `color.on-accent`, `color.green`, `color.hover`, `color.hover-2`, `color.accent`, `radius.control`, `text.xs`, `text.sm`, `duration.fast`, `duration.base`, `duration.press`, `easing.out-strong`

## Dependencies

- [Button](/components/button.md)

## Examples

### Create a project

React · `create-project.tsx`

```tsx
import { Steps, type StepsItem } from "@/components/ui/steps";

const items: StepsItem[] = [
  { title: "Repository", description: "From GitHub", content: "northwind/web-app, 1,284 commits on main." },
  { title: "Configure", description: "Build and env", content: "Next.js detected. Build with pnpm build, output .next." },
  { title: "Deploy", description: "Production", content: "The first deploy builds main and gives it a URL." },
];

export default function CreateProject() {
  return (
    <Steps
      className="w-80"
      defaultStep={1}
      controls
      nextLabel="Continue"
      completed="web-app is live on Production."
      items={items}
    />
  );
}
```

Vue · `create-project.vue`

```vue
<script setup lang="ts">
import { Steps, type StepsItem } from "@/components/ui/steps";

const items: StepsItem[] = [
  { title: "Repository", description: "From GitHub", content: "northwind/web-app, 1,284 commits on main." },
  { title: "Configure", description: "Build and env", content: "Next.js detected. Build with pnpm build, output .next." },
  { title: "Deploy", description: "Production", content: "The first deploy builds main and gives it a URL." },
];
</script>

<template>
  <Steps
    class="w-80"
    :defaultStep="1"
    controls
    nextLabel="Continue"
    completed="web-app is live on Production."
    :items="items"
  />
</template>
```

Svelte · `create-project.svelte`

```svelte
<script lang="ts">
  import { Steps, type StepsItem } from "$lib/components/ui/steps";

  const items: StepsItem[] = [
    { title: "Repository", description: "From GitHub", content: "northwind/web-app, 1,284 commits on main." },
    { title: "Configure", description: "Build and env", content: "Next.js detected. Build with pnpm build, output .next." },
    { title: "Deploy", description: "Production", content: "The first deploy builds main and gives it a URL." },
  ];
</script>

<Steps
  class="w-80"
  defaultStep={1}
  controls
  nextLabel="Continue"
  completed="web-app is live on Production."
  {items}
/>
```

### Deploy progress, read-only

React · `deploy-progress.tsx`

```tsx
import { Steps, type StepsItem } from "@/components/ui/steps";

/* read-only progress: linear, so the markers are not pressable; step says where the deploy is */
const items: StepsItem[] = [
  { title: "Queued", description: "10:42:01" },
  { title: "Building", description: "47s" },
  { title: "Running checks", description: "2 of 3 passed" },
  { title: "Live on Production" },
];

export default function DeployProgress() {
  return <Steps className="w-72" orientation="vertical" linear step={2} items={items} />;
}
```

Vue · `deploy-progress.vue`

```vue
<script setup lang="ts">
import { Steps, type StepsItem } from "@/components/ui/steps";

/* read-only progress: linear, so the markers are not pressable; step says where the deploy is */
const items: StepsItem[] = [
  { title: "Queued", description: "10:42:01" },
  { title: "Building", description: "47s" },
  { title: "Running checks", description: "2 of 3 passed" },
  { title: "Live on Production" },
];
</script>

<template>
  <Steps class="w-72" orientation="vertical" linear :step="2" :items="items" />
</template>
```

Svelte · `deploy-progress.svelte`

```svelte
<script lang="ts">
  import { Steps, type StepsItem } from "$lib/components/ui/steps";

  /* read-only progress: linear, so the markers are not pressable; step says where the deploy is */
  const items: StepsItem[] = [
    { title: "Queued", description: "10:42:01" },
    { title: "Building", description: "47s" },
    { title: "Running checks", description: "2 of 3 passed" },
    { title: "Live on Production" },
  ];
</script>

<Steps class="w-72" orientation="vertical" linear step={2} {items} />
```

### Import members with your own buttons

React · `import-members.tsx`

```tsx
import { useState } from "react";
import { Button } from "@/components/ui/button";
import { Steps } from "@/components/ui/steps";

const items = [{ title: "Upload CSV" }, { title: "Match columns" }, { title: "Invite" }];

/* your own buttons drive the step; the last one names what it does */
export default function ImportMembers() {
  const [step, setStep] = useState(0);
  const done = step === items.length;
  const last = step === items.length - 1;
  return (
    <div className="flex w-80 flex-col gap-4">
      <Steps linear step={step} onStepChange={setStep} items={items} />
      <div className="flex justify-end gap-2">
        <Button size="sm" disabled={step === 0 || done} onClick={() => setStep(step - 1)}>Back</Button>
        <Button size="sm" variant="primary" onClick={() => setStep(done ? 0 : step + 1)}>{done ? "Import more" : last ? "Invite 18 people" : "Next"}</Button>
      </div>
    </div>
  );
}
```

Vue · `import-members.vue`

```vue
<script setup lang="ts">
import { computed, ref } from "vue";
import { Button } from "@/components/ui/button";
import { Steps } from "@/components/ui/steps";

const items = [{ title: "Upload CSV" }, { title: "Match columns" }, { title: "Invite" }];

/* your own buttons drive the step; the last one names what it does */
const step = ref(0);
const done = computed(() => step.value === items.length);
const last = computed(() => step.value === items.length - 1);
</script>

<template>
  <div class="flex w-80 flex-col gap-4">
    <Steps v-model:step="step" linear :items="items" />
    <div class="flex justify-end gap-2">
      <Button size="sm" :disabled="step === 0 || done" @click="step = step - 1">Back</Button>
      <Button size="sm" variant="primary" @click="step = done ? 0 : step + 1">{{ done ? "Import more" : last ? "Invite 18 people" : "Next" }}</Button>
    </div>
  </div>
</template>
```

Svelte · `import-members.svelte`

```svelte
<script lang="ts">
  import { Button } from "$lib/components/ui/button";
  import { Steps } from "$lib/components/ui/steps";

  const items = [{ title: "Upload CSV" }, { title: "Match columns" }, { title: "Invite" }];

  /* your own buttons drive the step; the last one names what it does */
  let step = $state(0);
  const done = $derived(step === items.length);
  const last = $derived(step === items.length - 1);
</script>

<div class="flex w-80 flex-col gap-4">
  <Steps linear bind:step {items} />
  <div class="flex justify-end gap-2">
    <Button size="sm" disabled={step === 0 || done} onclick={() => (step = step - 1)}>Back</Button>
    <Button size="sm" variant="primary" onclick={() => (step = done ? 0 : step + 1)}>{done ? "Import more" : last ? "Invite 18 people" : "Next"}</Button>
  </div>
</div>
```

## Recipe

`steps.recipe.ts`:

```ts
import { tv, type VariantProps } from "../lib/tv";

/* steps — a multi-step flow (Zag steps through Ark UI): numbered markers joined by a rail.
 *
 * The model is the task rows (task-rows.recipe.ts): the 24px badge column, the completed mark (green
 * fill, white check that arrives scaled from 0.5 with its opacity, at the press timing), the 1px
 * rail in the line colour (w-px in the 24px column: its middle is 11.5px in), and the step
 * figure's 10.5px/600 tabular type. The markers' states come from the engine's attributes
 * (data-incomplete, data-current, data-complete) on the item's parts.
 *
 *   horizontal  markers in a row of equal columns, each step's text under its marker (it wraps in
 *               its column); the rail runs from this marker to the next at the markers' middle
 *   vertical    the rail runs down the marker column, from under the marker to the next one
 *
 * Motion: colours over duration.base; the check scales and fades in, and fades out faster; all instant from the
 * keyboard (kbd-instant on every part that moves). Transitions only, so nothing plays on first
 * paint. The trigger bleeds 6px (padding and negative margin) so the marker lines up with the
 * edge while the hover fill has room. Back and Next are the real Button, marked data-steps.
 * Parts are found by data-slot (steps, steps-list, steps-item, …). */

export const steps = tv({
  slots: {
    base: "flex w-full min-w-0 flex-col gap-4",
    list: "flex min-w-0",
    item: "flex min-w-0",
    trigger: [
      "flex min-w-0 items-start gap-2.5 -m-1.5 p-1.5 rounded-control text-start",
      "motion-colors-fast kbd:duration-0",
    ],
    indicator: [
      "kbd-instant",
      "grid shrink-0 size-6 place-items-center rounded-[50%] border border-solid [&>*]:[grid-area:1/1]",
      "border-line-strong bg-transparent text-ink-2 motion-colors-base",
      "data-current:border-ink data-current:bg-ink data-current:text-on-ink",
      "data-complete:border-green data-complete:bg-green data-complete:text-on-accent",
    ],
    number: [
      "kbd-instant",
      "text-[10.5px] font-semibold leading-none tabular-nums opacity-100 motion-opacity-base",
      "[[data-slot=steps-indicator][data-complete]>&]:opacity-0",
    ],
    /* in: scaled from 0.5 with its opacity (the task rows' mark). Out (a step undone by Back or an
     * earlier marker): shorter and simpler, it fades over `fast` and its scale resets once the fade
     * is over. Reduced motion: no scale, the check fades both ways. */
    check: [
      "kbd-instant",
      "flex text-[13px] opacity-0 [transform:scale(0.5)] motion-reduce:[transform:none]",
      "[transition:opacity_var(--fndn-duration-fast)_ease,transform_0ms_linear_var(--fndn-duration-fast)]",
      "[[data-slot=steps-indicator][data-complete]>&]:opacity-100 [[data-slot=steps-indicator][data-complete]>&]:[transform:none]",
      "[[data-slot=steps-indicator][data-complete]>&]:motion-opacity-base [[data-slot=steps-indicator][data-complete]>&]:motion-transform-press",
    ],
    text: "flex min-w-0 flex-col",
    title: [
      "text-sm font-medium leading-normal text-ink-2 wrap-break-word [unicode-bidi:plaintext] [&:dir(ltr)]:text-left [&:dir(rtl)]:text-right",
      "[[data-slot=steps-trigger]:is([data-current],[data-complete])_&]:text-ink",
    ],
    description: "text-xs leading-normal text-ink-2 wrap-break-word [unicode-bidi:plaintext] [&:dir(ltr)]:text-left [&:dir(rtl)]:text-right",
    separator: "kbd-instant w-px h-px shrink-0 bg-line motion-colors-base data-complete:bg-green",
    content: "text-sm leading-normal text-ink-2 wrap-break-word [unicode-bidi:plaintext]",
    completed: "text-sm leading-normal text-ink-2 wrap-break-word [unicode-bidi:plaintext]",
    footer: "flex flex-wrap items-center justify-end gap-2",
  },
  variants: {
    orientation: {
      horizontal: {
        /* equal columns; the text sits under its marker, so a long title wraps in its own column
         * and a crowded row never squeezes a neighbour */
        list: "items-start",
        item: "relative flex-1 basis-0 flex-col",
        trigger: "flex-col max-w-full gap-1.5",
        title: "wrap-anywhere",
        description: "wrap-anywhere",
        /* from 6px after this marker to 6px before the next one, at the marker's middle */
        separator: "absolute top-[11.5px] start-[30px] end-1.5 w-auto",
      },
      vertical: {
        list: "flex-col",
        item: "relative flex-col pb-5 last:pb-0",
        /* beside the marker, the title's first line is the marker's 24px line (horizontal: under
         * the marker, every line keeps the body leading) */
        title: "first-line:leading-6",
        /* the fill bleeds at the start only, so the row ends on the list's edge */
        trigger: "me-0",
        /* down the marker column: from 4px under this marker to 4px above the next one (12px of
         * rail between two steps without a description) */
        separator: "absolute start-[11.5px] top-7 bottom-1 h-auto",
      },
    },
    /* not linear: a marker is pressable (a row's press: background only) */
    linear: {
      false: { trigger: "cursor-pointer hover:bg-hover active:bg-hover-2" },
      true: { trigger: "cursor-default" },
    },
  },
  defaultVariants: { orientation: "horizontal", linear: false },
});

export type StepsRecipeProps = VariantProps<typeof steps>;
```
