# Stepper

> A multi-step progress indicator on light rails: each completed step sends a single sweep of light down the rail to the next, the current bullet breathes a soft halo, and each check draws itself.

- Package: `fancy-ui-svelte` (Svelte 5 + Tailwind CSS v4)
- Category: Navigation
- Tags: stepper, steps, wizard, progress, compound, navigation
- Types: `StepperProps`, `StepProps`, `StepperContext`
- Docs: https://fancy-ui.rama.app/docs/components/stepper
- Source: https://github.com/RamaHerbin/fancy-ui/tree/main/src/lib/fancy-ui/stepper

## Import

```svelte
<script lang="ts">
  import { Stepper } from 'fancy-ui-svelte';
</script>
```

Setup (once per project): `npm install fancy-ui-svelte`, then add `@import "fancy-ui-svelte/tailwind.css";` after `@import "tailwindcss";` in your main CSS file. Full guide: https://fancy-ui.rama.app/llms.txt

React: `import { Stepper } from 'fancy-ui-react';` (`class` becomes `className`, snippets become `ReactNode`, DOM callbacks are camel-cased; exact names on https://fancy-ui.rama.app/docs/components/react/stepper.md).

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `current` | `number` | `0` | The active step's 0-based index. Bindable. |
| `onCurrentChange` | `(current: number) => void` | — | Called with the new index whenever it changes, however the change happened. |
| `orientation` | `"horizontal" \| "vertical"` | `"horizontal"` | The rail's stacking axis. |
| `clickable` | `boolean` | `false` | Whether steps render as buttons a reader can click to jump between them. |
| `onStepClick` | `(index: number) => void` | — | Called with a step's index when it's activated by a click. Only fires when clickable. |
| `class` | `string` | — | Additional CSS classes, merged onto the root. |
| `ref` | `HTMLOListElement \| null` | `null` | Bindable reference to the root element. |
| `sound` | `boolean` | `false` | Plays select when a clickable step changes the current step, once the user has enabled sound |
| `Step.label` (required) | `string` | — | The step's primary label. |
| `Step.description` | `string` | — | Optional secondary line shown under the label. |
| `Step.class` | `string` | — | Additional CSS classes, merged onto the step's li. |
| `Step.ref` | `HTMLLIElement \| null` | `null` | Bindable reference to the step's li element. |

## Snippets

| Snippet | Description |
| --- | --- |
| `children` | The Steps. |
| `Step.children` | Overrides the bullet's default content (checkmark / number / outline). |

## Examples

### Basic Usage

A four-step wizard in a nested frame; Continue and Back run the light along the rails.

```svelte
<script lang="ts">
	import { Stepper, Step } from "fancy-ui-svelte";

	const steps = [
		{ label: "Account", description: "Sign-in details" },
		{ label: "Workspace", description: "Name and region" },
		{ label: "Invite", description: "Bring your team" },
		{ label: "Launch", description: "Review and go" },
	];

	let current = $state(2);
</script>

<div
	class="w-full max-w-2xl rounded-[22px] border border-black/[0.08] bg-[#f4f4f5] p-1.5 dark:border-white/[0.08] dark:bg-[#0b0b0c]"
>
	<div
		class="rounded-2xl border border-black/[0.08] bg-[#fafafa] shadow-[0_1px_2px_rgb(0_0_0/0.04)] dark:border-white/[0.06] dark:bg-[#141416] dark:shadow-none"
	>
		<div
			class="flex items-center justify-between border-b border-black/[0.06] px-5 py-3 dark:border-white/[0.06]"
		>
			<span class="text-foreground text-[13px] font-medium">New workspace</span>
			<span class="text-muted-foreground font-mono text-[11px] tabular-nums">
				{String(current + 1).padStart(2, "0")} / {String(steps.length).padStart(2, "0")}
			</span>
		</div>

		<div class="px-4 pt-7 pb-6 sm:px-6">
			<Stepper bind:current>
				{#each steps as step (step.label)}
					<Step label={step.label} description={step.description} />
				{/each}
			</Stepper>
		</div>

		<div
			class="flex items-center justify-between border-t border-black/[0.06] px-5 py-3 dark:border-white/[0.06]"
		>
			<button
				type="button"
				class="text-muted-foreground hover:text-foreground rounded-md px-2.5 py-1.5 text-[13px] transition-colors disabled:pointer-events-none disabled:opacity-40"
				disabled={current === 0}
				onclick={() => (current = Math.max(0, current - 1))}
			>
				Back
			</button>
			<button
				type="button"
				class="rounded-lg border border-black/[0.08] bg-white px-3.5 py-1.5 text-[13px] font-medium text-neutral-900 shadow-[0_1px_2px_rgb(0_0_0/0.06)] transition-colors hover:bg-neutral-50 dark:border-white/[0.1] dark:bg-white/[0.06] dark:text-neutral-100 dark:shadow-none dark:hover:bg-white/[0.1]"
				onclick={() => (current = current === steps.length - 1 ? 0 : current + 1)}
			>
				{current === steps.length - 1 ? "Start over" : "Continue"}
			</button>
		</div>
	</div>
</div>
```

### Vertical Stepper

Stacked in a column; the rails fill top to bottom.

```svelte
<script lang="ts">
	import { Stepper, Step } from "fancy-ui-svelte";

	let current = $state(2);
</script>

<div
	class="w-full max-w-xs rounded-[20px] border border-black/[0.08] bg-[#f4f4f5] p-1.5 dark:border-white/[0.08] dark:bg-[#0b0b0c]"
>
	<div
		class="rounded-[14px] border border-black/[0.08] bg-[#fafafa] p-5 dark:border-white/[0.06] dark:bg-[#141416]"
	>
		<Stepper bind:current orientation="vertical">
			<Step label="Account" />
			<Step label="Profile" />
			<Step label="Billing" />
			<Step label="Confirmation" />
		</Stepper>
	</div>
</div>
```

### Clickable Steps

Jump to any step; a jump across several steps lights the rails one after another.

```svelte
<script lang="ts">
	import { Stepper, Step } from "fancy-ui-svelte";

	let current = $state(0);
	let lastClicked = $state<number | null>(null);

	function onStepClick(index: number) {
		lastClicked = index;
	}
</script>

<div
	class="w-full max-w-xl rounded-[20px] border border-black/[0.08] bg-[#f4f4f5] p-1.5 dark:border-white/[0.08] dark:bg-[#0b0b0c]"
>
	<div
		class="rounded-[14px] border border-black/[0.08] bg-[#fafafa] px-4 pt-6 pb-4 sm:px-6 dark:border-white/[0.06] dark:bg-[#141416]"
	>
		<Stepper sound bind:current clickable {onStepClick}>
			<Step label="Account" />
			<Step label="Profile" />
			<Step label="Billing" />
			<Step label="Confirmation" />
		</Stepper>
		<p class="text-muted-foreground mt-5 text-center text-xs" aria-live="polite">
			{#if lastClicked !== null}
				Jumped to step {lastClicked + 1}.
			{:else}
				Click the last step to send light down every rail.
			{/if}
		</p>
	</div>
</div>
```

### With Descriptions

Vertical, clickable, with a secondary line under each label.

```svelte
<script lang="ts">
	import { Stepper, Step } from "fancy-ui-svelte";

	let current = $state(1);
</script>

<div
	class="w-full max-w-sm rounded-[20px] border border-black/[0.08] bg-[#f4f4f5] p-1.5 dark:border-white/[0.08] dark:bg-[#0b0b0c]"
>
	<div
		class="rounded-[14px] border border-black/[0.08] bg-[#fafafa] p-5 dark:border-white/[0.06] dark:bg-[#141416]"
	>
		<Stepper bind:current orientation="vertical" clickable>
			<Step label="Account" description="Create your login" />
			<Step label="Profile" description="Tell us about yourself" />
			<Step label="Billing" description="Pick a plan" />
			<Step label="Confirmation" description="Review and finish" />
		</Stepper>
	</div>
</div>
```
