# Introduction

> Typed multi-step flows for Solid, from one definition.

Framework: Solid (`@stepperize/solid`), Stepperize v9.
Source: https://stepperize.com/docs/v9/solid

Stepperize is for flows where someone moves through named steps: checkout,
onboarding, surveys, import wizards, approval flows and multi-step forms.

You describe the steps once. The definition gives you a typed, reactive
stepper, a provider and a set of accessible, unstyled components that all share
the same step ids.

```tsx
import { defineStepper } from "@stepperize/solid";
import { Match, Switch } from "solid-js";
import { z } from "zod";

const checkout = defineStepper([
  { id: "shipping", title: "Shipping", schema: z.object({ address: z.string().min(1) }) },
  { id: "payment", title: "Payment", schema: z.object({ card: z.string().length(16) }) },
  { id: "review", title: "Review" },
]);

function Checkout() {
  const stepper = checkout.useStepper({ onFinish: (output) => placeOrder(output) });

  return (
    <section>
      <h2>{stepper.current.title}</h2>

      <Switch>
        <Match when={stepper.current.id === "shipping"}><ShippingForm /></Match>
        <Match when={stepper.current.id === "payment"}><PaymentForm /></Match>
        <Match when={stepper.current.id === "review"}><Review data={stepper.data} /></Match>
      </Switch>

      <button type="button" disabled={stepper.isFirst} onClick={() => stepper.prev()}>
        Back
      </button>
      <button type="button" onClick={() => stepper.next(readForm())}>
        {stepper.isLast ? "Place order" : "Continue"}
      </button>
    </section>
  );
}
```

A flow built with the primitives, running:

The live demo runs in the browser. Its source ([solid/SolidDemo.tsx](https://github.com/damianricobelli/stepperize/blob/main/apps/docs/src/components/framework-demos/solid/SolidDemo.tsx)):

```tsx
/** @jsxImportSource solid-js */
import { defineStepper } from "@stepperize/solid";
import { Show } from "solid-js";

const { Stepper } = defineStepper([
	{ id: "account", title: "Account", description: "Who you are" },
	{ id: "plan", title: "Plan", description: "What you need" },
	{ id: "done", title: "Done", description: "All set" },
]);

export default function SolidDemo() {
	return (
		<Stepper.Root
			class="not-prose my-4 flex flex-col gap-4 rounded-lg border p-4 text-sm"
			data-demo="solid"
		>
			{(stepper) => (
				<>
					<Stepper.List class="flex gap-2">
						{(_step, index) => (
							<Stepper.Item class="flex-1">
								<Stepper.Trigger class="flex w-full items-center gap-2 rounded-md border px-3 py-2 text-left data-[state=current]:border-fd-primary data-[state=current]:bg-fd-accent">
									<Stepper.Indicator class="flex size-6 shrink-0 items-center justify-center rounded-full border text-xs data-[state=complete]:bg-fd-primary data-[state=complete]:text-fd-primary-foreground">
										{index + 1}
									</Stepper.Indicator>
									<span class="flex flex-col">
										<Stepper.Title class="font-medium" />
										<Stepper.Description class="text-xs text-fd-muted-foreground" />
									</span>
								</Stepper.Trigger>
							</Stepper.Item>
						)}
					</Stepper.List>

					<Stepper.Content step="account" class="rounded-md bg-fd-muted p-3">
						Create your account.
					</Stepper.Content>
					<Stepper.Content step="plan" class="rounded-md bg-fd-muted p-3">
						Pick the plan that fits.
					</Stepper.Content>
					<Stepper.Content step="done" class="rounded-md bg-fd-muted p-3">
						<Show
							when={stepper.isFinished}
							fallback="Press Finish to complete the flow."
						>
							Finished. Thanks!
						</Show>
					</Stepper.Content>

					<div class="flex items-center gap-2">
						<Stepper.Prev class="rounded-md border px-3 py-1 disabled:opacity-40">
							Back
						</Stepper.Prev>
						<Stepper.Next class="rounded-md border px-3 py-1 aria-disabled:opacity-40">
							{stepper.isLast ? "Finish" : "Continue"}
						</Stepper.Next>
						<span data-step class="ml-auto text-xs text-fd-muted-foreground">
							Step {stepper.index + 1} of {stepper.steps.length}
						</span>
					</div>
				</>
			)}
		</Stepper.Root>
	);
}
```

## Is it a form library?

No. Stepperize owns the **flow**: which step is current, moving between steps,
what each step saved and which steps are complete. Your signals, a store or
your form library own the fields. See [Forms](https://stepperize.com/docs/v9/solid/guides/forms).

## What you get

- **One call moves forward.** `next(data)` saves the step's data, validates it
  against the step's schema and moves on. It resolves with what happened
  instead of throwing.
- **Typed everywhere.** Step ids, each step's data and your own fields
  (`title`, `icon`, anything) are inferred from the definition.
- **Fine-grained.** The stepper is a reactive object, like props: JSX, memos
  and effects follow exactly what they read.
- **Branching as data.** A `next` map decides where each step leads from its
  validated data, and a flow can have more than one ending.
- **Resumable.** One `snapshot` goes in, one `onChange` comes out. The current
  step can follow the URL with a single option.
- **Accessible primitives.** Roles, keyboard navigation, focus and
  announcements are handled for you.
- **Server rendering.** It renders in SolidStart and hydrates in place.
- **Small.** About 3.3 KiB for the stepper and 6.8 KiB with the primitives,
  min + gzip, with no third-party dependencies.

## The same flow as every other binding

The state machine is [`@stepperize/core`](https://stepperize.com/docs/v9/core), shared by every
binding, so the concepts are the same everywhere. Each has its own page,
with Solid code: [steps](https://stepperize.com/docs/v9/solid/concepts/steps),
[the lifecycle of a move](https://stepperize.com/docs/v9/solid/concepts/moves),
[step state](https://stepperize.com/docs/v9/solid/concepts/step-state),
[validation](https://stepperize.com/docs/v9/solid/guides/validation),
[branching](https://stepperize.com/docs/v9/solid/guides/branching) and
[persistence](https://stepperize.com/docs/v9/solid/guides/persistence).

## Next

- [Installation](https://stepperize.com/docs/v9/solid/installation): Add the package to a Solid project.

- [Your first stepper](https://stepperize.com/docs/v9/solid/first-stepper): A working flow, built in four small steps.

- [Primitives](https://stepperize.com/docs/v9/solid/guides/primitives): Accessible components bound to your steps.

- [Without Solid](https://stepperize.com/docs/v9/core): The same state machine in tests, servers and agents.
