### Install Conform with Zod Source: https://stepperize.vercel.app/docs/react/examples/forms Install the Conform form library along with Zod for validation. ```bash pnpm add @conform-to/react @conform-to/zod zod ``` -------------------------------- ### Full Example: Minimal Stepper Component Source: https://stepperize.vercel.app/docs/react/my-first-stepper A complete React component demonstrating the minimal stepper setup using defineStepper and useStepper, including navigation buttons and conditional rendering for step content. ```typescript import React from "react"; import { defineStepper } from "@stepperize/react"; const { useStepper } = defineStepper( { id: "name", title: "Name" }, { id: "email", title: "Email" }, { id: "confirm", title: "Confirm" }, { id: "done", title: "Done" }, ); export function MyFirstStepper() { const stepper = useStepper(); return ( <>

Step: {stepper.state.current.data.title}

{stepper.flow.switch({ name: () =>

What is your name?

, email: () =>

What is your email?

, confirm: () =>

Please confirm your details.

, done: () =>

All done!

, })}
{stepper.state.isLast ? ( ) : ( <> )}
); } ``` -------------------------------- ### Full Example with Custom Styling and Content Source: https://stepperize.vercel.app/docs/react/examples/basic A comprehensive example integrating custom step indicators, styled triggers, and content for each step. It also includes navigation buttons and conditional rendering for the reset option. ```jsx import React from "react"; import { defineStepper } from "@stepperize/react"; import { useStepItemContext } from "@stepperize/react/primitives"; const { Stepper } = defineStepper( { id: "a", title: "First" }, { id: "b", title: "Second" }, { id: "c", title: "Third" } ); function StepNumber() { const item = useStepItemContext(); return {item.index + 1}; } function Trigger({ children }: { children: React.ReactNode }) { return ( {children} ); } export function StepperWithNumberedIndicator() { return ( {({ stepper }) => ( <> {stepper.state.all.map((step) => ( {step.title}} /> {step.id !== "c" && } ))}

First step content

Second step content

Third step content

{stepper.state.isLast ? ( ) : ( <> Previous Next )}
)}
); } ``` -------------------------------- ### Full Example: Custom Step Indicator Source: https://stepperize.vercel.app/docs/react/examples/basic A comprehensive example demonstrating how to implement custom step indicators using render props within `Stepper.Indicator` for enhanced visual feedback. ```javascript import { Stepper } from "stepperize"; const steps = [ { id: "details", label: "Details" }, { id: "plan", label: "Plan" }, { id: "payment", label: "Payment" }, ]; function CustomIndicatorStepper() { return ( { (step) => ( { (state) => ( {state.index + 1} ) } {step.label} ) }

Enter your details here.

Choose your plan.

Enter your payment information.

); } ``` -------------------------------- ### Complete Stepper Example Source: https://stepperize.vercel.app/docs/react/api-references/primitives This example demonstrates how to use the Stepper primitives to build a complete checkout stepper UI. It includes the list of steps, content for each step, and navigation actions. Ensure Stepper.Root is used to provide the stepper state. ```jsx import React from "react" import { defineStepper } from "@stepperize/react" const { Stepper } = defineStepper( { id: "shipping", title: "Shipping" }, { id: "payment", title: "Payment" }, { id: "confirmation", title: "Confirmation" } ); function CheckoutStepper() { return ( {({ stepper }) => ( <> {stepper.state.all.map((step) => ( {step.title} ))} Shipping form here Payment form here Confirmation here Previous Next )} ); } ``` -------------------------------- ### Install TanStack Form with Zod Source: https://stepperize.vercel.app/docs/react/examples/forms Install TanStack Form and Zod for form handling and validation. ```bash pnpm add @tanstack/react-form zod ``` -------------------------------- ### Install @stepperize/react with Bun Source: https://stepperize.vercel.app/docs/react/installation Use this command to add @stepperize/react to your project if you are using Bun as your package manager. ```bash bun add @stepperize/react ``` -------------------------------- ### Scoped Component - Props Source: https://stepperize.vercel.app/docs/react/api-references/scoped Details the available props for the Scoped component, including `initialStep` for setting the starting step and `initialMetadata` for pre-populating step-specific data. It also shows how to use these props in a practical example. ```APIDOC ## Scoped Component - Props ### Description The `Scoped` component accepts several props to configure the initial state of the stepper. ### Props Name| Type| Description ---|---|--- `initialStep`| `Get.Id`| Initial active step ID `initialMetadata`| `Partial, Metadata>>`| Initial metadata per step `children`| `React.ReactNode`| Content to render ### Usage with Props ```jsx import React from "react"; import { defineStepper } from "@stepperize/react"; const { Scoped, useStepper } = defineStepper( { id: "first", title: "First" }, { id: "second", title: "Second" }, { id: "last", title: "Last" } ); export const MyScopedStepper = () => ( ); const StepContent = () => { const stepper = useStepper(); return
Current: {stepper.state.current.data.title}
; }; ``` ``` -------------------------------- ### Full Example: Horizontal Stepper Source: https://stepperize.vercel.app/docs/react/examples/basic A complete example of a horizontal stepper, integrating all the necessary components for step definition, navigation, and content display. ```javascript import { Stepper } from "stepperize"; const steps = [ { id: "details", label: "Details" }, { id: "plan", label: "Plan" }, { id: "payment", label: "Payment" }, ]; function HorizontalStepper() { return ( { (step) => ( {step.label} ) }

Enter your details here.

Choose your plan.

Enter your payment information.

); } ``` -------------------------------- ### Full Example: Vertical Stepper Source: https://stepperize.vercel.app/docs/react/examples/basic A complete example of a vertical stepper, demonstrating the use of the `orientation='vertical'` prop for a different layout. ```javascript import { Stepper } from "stepperize"; const steps = [ { id: "details", label: "Details" }, { id: "plan", label: "Plan" }, { id: "payment", label: "Payment" }, ]; function VerticalStepper() { return ( { (step) => ( {step.label} ) }

Enter your details here.

Choose your plan.

Enter your payment information.

); } ``` -------------------------------- ### Install @stepperize/react with PNPM Source: https://stepperize.vercel.app/docs/react/installation Use this command to add @stepperize/react to your project if you are using PNPM as your package manager. ```bash pnpm install @stepperize/react ``` -------------------------------- ### Install @stepperize/react with NPM Source: https://stepperize.vercel.app/docs/react/installation Use this command to add @stepperize/react to your project if you are using NPM as your package manager. ```bash npm install @stepperize/react ``` -------------------------------- ### Install React Hook Form with Zod Source: https://stepperize.vercel.app/docs/react/examples/forms Install React Hook Form and the Zod resolver for validation. ```bash pnpm add react-hook-form @hookform/resolvers zod ``` -------------------------------- ### Install @stepperize/react with Yarn Source: https://stepperize.vercel.app/docs/react/installation Use this command to add @stepperize/react to your project if you are using Yarn as your package manager. ```bash yarn add @stepperize/react ``` -------------------------------- ### Stepper State and Navigation Example Source: https://stepperize.vercel.app/docs/react/api-references/hook Demonstrates accessing stepper state properties like `current`, `isFirst`, and `isLast`, and utilizing navigation methods such as `next()`, `prev()`, `goTo(id)`, and `reset()`. ```javascript import React from "react"; import { defineStepper } from "@stepperize/react"; const { useStepper } = defineStepper( { id: "info", title: "Info" }, { id: "review", title: "Review" }, { id: "done", title: "Done" } ); function NavExample() { const stepper = useStepper(); return (

Step {stepper.state.current.index + 1}: {stepper.state.current.data.title}

); } ``` -------------------------------- ### Horizontal Stepper Example Source: https://stepperize.vercel.app/docs/react/examples/basic Implement a horizontal stepper with navigation controls. Use this for sequential processes where a clear left-to-right flow is desired. ```jsx import React from "react"; import { defineStepper } from "@stepperize/react"; const { Stepper } = defineStepper( { id: "account", title: "Account" }, { id: "profile", title: "Profile" }, { id: "done", title: "Done" } ); function Trigger({ children }: { children: React.ReactNode }) { return ( {children} ); } export function HorizontalStepper() { return ( {({ stepper }) => ( <> {stepper.state.all.map((step) => ( {step.title}} /> {step.id !== "done" && } ))}

Account form

Profile form

All done!

{stepper.state.isLast ? ( ) : ( <> Previous Next )}
)}
); } ``` -------------------------------- ### Stepper Step Lookup Example Source: https://stepperize.vercel.app/docs/react/api-references/hook Illustrates using lookup helpers to retrieve step objects by ID or index, and to find neighboring steps. Access these via `stepper.lookup`. ```javascript import React from "react"; import { defineStepper } from "@stepperize/react"; const { useStepper } = defineStepper( { id: "info", title: "Info" }, { id: "review", title: "Review" }, { id: "done", title: "Done" } ); function LookupExample() { const stepper = useStepper(); const step = stepper.lookup.get("review"); const neighbors = stepper.lookup.getNeighbors(stepper.state.current.data.id); return (

Review: {step?.title ?? "not found"}; neighbors: {neighbors.prev?.id ?? "none"} → {neighbors.next?.id ?? "none"}

); } ``` -------------------------------- ### Stepper.Prev Button Examples Source: https://stepperize.vercel.app/docs/react/api-references/primitives Use Stepper.Prev for navigating to the previous step. It's automatically disabled on the first step. Custom click handlers and disabled states can be configured. ```jsx {/* Default behavior */} Previous ``` ```jsx {/* Custom disabled behavior */} Back ``` ```jsx {/* Custom click handler */} { console.log("Going back"); stepper.navigation.prev(); }}> Previous ``` -------------------------------- ### Vertical Stepper Example Source: https://stepperize.vercel.app/docs/react/examples/basic Implement a vertical stepper by passing orientation="vertical" to Stepper.Root and Stepper.List. This is suitable for processes that benefit from a top-to-bottom flow. ```jsx import React from "react"; import { defineStepper } from "@stepperize/react"; const { Stepper } = defineStepper( { id: "one", title: "Step 1" }, { id: "two", title: "Step 2" }, { id: "three", title: "Step 3" } ); function Trigger({ children }: { children: React.ReactNode }) { return ( {children} ); } function VerticalLine() { return
; } export function VerticalStepper() { return ( {({ stepper }) => ( <> {stepper.state.all.map((step, index) => ( {step.title}} /> {index < stepper.state.all.length - 1 && } ))}
{stepper.state.all.map((step) => (

Content for {step.title}

))}
{stepper.state.isLast ? ( ) : ( <> Back Continue )}
)}
); } ``` -------------------------------- ### Add Navigation Controls (next / prev / reset) Source: https://stepperize.vercel.app/docs/react/examples/scoped Implement navigation buttons using `stepper.state.isFirst`, `stepper.state.isLast`, and `stepper.navigation.next()`, `prev()`, `reset()`. This example shows conditional rendering for 'Back', 'Next', and 'Reset' buttons. ```javascript import React from "react"; import { defineStepper } from "@stepperize/react"; const { Scoped, useStepper } = defineStepper( { id: "info", title: "Info" }, { id: "review", title: "Review" }, { id: "done", title: "Done" } ); function StepNavigation() { const stepper = useStepper(); return (
{stepper.state.isLast ? ( ) : (
{!stepper.state.isFirst && ( )}
)}
); } ``` -------------------------------- ### Implement onBeforeTransition Hook Source: https://stepperize.vercel.app/docs/react/api-references/hook Use `stepper.lifecycle.onBeforeTransition` to run logic before a step transition. Return `false` to cancel the transition. This example shows a confirmation dialog before navigating back. ```javascript import React from "react"; import { defineStepper } from "@stepperize/react"; const { useStepper } = defineStepper( { id: "first", title: "First" }, { id: "second", title: "Second" } ); function MyStepper() { const stepper = useStepper(); React.useEffect(() => { const unsub = stepper.lifecycle.onBeforeTransition(async (ctx) => { if (ctx.direction === "prev" && !window.confirm("Go back?")) return false; }); return () => unsub(); }, [stepper]); return ( ); } ``` -------------------------------- ### Define and Use a Complete Stepper Component Source: https://stepperize.vercel.app/docs/react/api-references/primitives This example demonstrates how to define a fully-typed stepper component using `defineStepper` and render it with a list, content, and navigation controls. It includes imports for React and the `defineStepper` function. ```jsx import React from "react" import { defineStepper } from "@stepperize/react" const { Stepper, useStepper } = defineStepper( { id: "account", title: "Account", description: "Create your account" }, { id: "profile", title: "Profile", description: "Set up your profile" }, { id: "complete", title: "Complete", description: "All done!" } ); function OnboardingStepper() { return ( {({ stepper }) => (
{/* Step list */} {stepper.state.all.map((step) => (
{step.title} {step.description}
))}
{/* Step content */}

Create Account

Enter your email and password

Set Up Profile

Tell us about yourself

All Done!

Your account is ready

{/* Navigation */} Previous {stepper.state.isLast ? "Finish" : "Next"}
)}
); } ``` -------------------------------- ### Full Multi-Step Form with Stepperize and TanStack Form Source: https://stepperize.vercel.app/docs/react/examples/forms This is a complete example of a multi-step form. It defines schemas for each step, uses `defineStepper` to create the stepper context, and `useForm` for form management and validation. It handles navigation between steps and displays validation errors. ```jsx "use client"; import { useForm } from "@tanstack/react-form"; import { z } from "zod"; import { defineStepper } from "@stepperize/react"; const PersonalSchema = z.object({ name: z.string().min(1, "Name required"), email: z.email("Invalid email"), }); const AddressSchema = z.object({ street: z.string().min(1, "Street required"), city: z.string().min(1, "City required"), }); const { Scoped, useStepper } = defineStepper( { id: "personal", title: "Personal", schema: PersonalSchema }, { id: "address", title: "Address", schema: AddressSchema }, { id: "done", title: "Done" } ); type FormValues = { name: string; email: string; street: string; city: string }; function StepForm() { const stepper = useStepper(); const stepData = stepper.state.current.data; const schema = "schema" in stepData && stepData.schema ? (stepData.schema as z.ZodType) : z.object({}); const form = useForm({ defaultValues: { name: "", email: "", street: "", city: "" }, validators: { onChange: schema }, onSubmit: ({ value }) => { if (!stepper.state.isLast) stepper.navigation.next(); }, }); if (stepper.flow.is("done")) return

All done!

; return (
{ e.preventDefault(); e.stopPropagation(); form.handleSubmit(); }}> {stepper.flow.switch({ personal: () => (
(
field.handleChange(e.target.value)} /> {field.state.meta.isTouched && field.state.meta.errors?.length ? {field.state.meta.errors.map((e) => (typeof e === "object" && e && "message" in e ? (e as { message: string }).message : String(e))).join(", ")} : null}
)} /> (
field.handleChange(e.target.value)} /> {field.state.meta.isTouched && field.state.meta.errors?.length ? {field.state.meta.errors.map((e) => (typeof e === "object" && e && "message" in e ? (e as { message: string }).message : String(e))).join(", ")} : null}
)} />
), address: () => (
(
field.handleChange(e.target.value)} /> {field.state.meta.isTouched && field.state.meta.errors?.length ? {field.state.meta.errors.map((e) => (typeof e === "object" && e && "message" in e ? (e as { message: string }).message : String(e))).join(", ")} : null}
)} /> (
field.handleChange(e.target.value)} /> {field.state.meta.isTouched && field.state.meta.errors?.length ? {field.state.meta.errors.map((e) => (typeof e === "object" && e && "message" in e ? (e as { message: string }).message : String(e))).join(", ")} : null}
)} />
), done: () => null, })}
); } function StepNavigation() { const stepper = useStepper(); return (
{!stepper.state.isFirst && } {stepper.state.isLast && }
); } export function TanStackStepperForm() { return ( ); } ``` -------------------------------- ### Conform Stepper Form Example Source: https://stepperize.vercel.app/docs/react/examples/forms Integrates Stepperize with Conform for managing multi-step form state and validation. Use this for forms requiring complex validation logic handled by Conform. ```typescript "use client"; import { getFormProps, useForm } from "@conform-to/react"; import { parseWithZod } from "@conform-to/zod/v4/future"; import { z } from "zod"; import { defineStepper } from "@stepperize/react"; const PersonalSchema = z.object({ name: z.string().min(1, "Name required"), email: z.email("Invalid email"), }); const AddressSchema = z.object({ street: z.string().min(1, "Street required"), city: z.string().min(1, "City required"), }); const { Scoped, useStepper } = defineStepper( { id: "personal", title: "Personal", schema: PersonalSchema }, { id: "address", title: "Address", schema: AddressSchema }, { id: "done", title: "Done" } ); function StepForm() { const stepper = useStepper(); const stepData = stepper.state.current.data; const schema = "schema" in stepData && stepData.schema ? stepData.schema : undefined; const [form, fields] = useForm({ onValidate({ formData }) { return schema ? parseWithZod(formData, { schema }) : parseWithZod(formData, { schema: z.object({}) }); }, onSubmit(e, { formData }) { e.preventDefault(); const result = schema ? parseWithZod(formData, { schema }) : parseWithZod(formData, { schema: z.object({}) }); if (result.status === "success" && !stepper.state.isLast) stepper.navigation.next(); }, }); if (stepper.flow.is("done")) return

All done!

; return (
{stepper.flow.switch({ personal: () => ( <>
), address: () => ( <>
), done: () => null, })}
); } function StepNavigation() { const stepper = useStepper(); return (
{!stepper.state.isFirst && } {stepper.state.isLast && }
); } export function ConformStepperForm() { return ( ); } ``` -------------------------------- ### Stepper.Root Component Source: https://stepperize.vercel.app/docs/react/api-references/scoped Explains `Stepper.Root` as a convenience wrapper that internally uses `Scoped` and provides access to the stepper instance via a render prop. It simplifies initial state setup using `initialStep` and `initialMetadata`. ```APIDOC ## Stepper.Root Component ### Description `Stepper.Root` is a component that wraps your stepper content and provides the stepper instance through a render prop. It internally utilizes the `Scoped` component and accepts `initialStep` and `initialMetadata` props to configure the initial state. ### Usage ```jsx import React from "react"; import { defineStepper } from "@stepperize/react"; const { Stepper, useStepper } = defineStepper( { id: "first", title: "First" }, { id: "second", title: "Second" } ); export const MyStepper = () => ( {({ stepper }) => (

Current: {stepper.state.current.data.title}

)}
); ``` ``` -------------------------------- ### Scoped Stepper with Initial State Source: https://stepperize.vercel.app/docs/react/api-references/scoped Configure the initial step and metadata for a stepper using the `initialStep` and `initialMetadata` props on the Scoped component. This sets the starting point and pre-defined states for your stepper. ```jsx import React from "react"; import { defineStepper } from "@stepperize/react"; const { Scoped, useStepper } = defineStepper( { id: "first", title: "First" }, { id: "second", title: "Second" }, { id: "last", title: "Last" } ); export const MyScopedStepper = () => ( ); const StepContent = () => { const stepper = useStepper(); return
Current: {stepper.state.current.data.title}
; }; ``` -------------------------------- ### Manage Step Metadata with set, get, and reset Source: https://stepperize.vercel.app/docs/react/api-references/hook Use `stepper.metadata.set(id, values)` to save metadata for a specific step, `stepper.metadata.get(id)` to retrieve it, and `stepper.metadata.reset(keepInitialMetadata?)` to clear it. You can also manage metadata for the current step directly. ```javascript import React from "react"; import { defineStepper } from "@stepperize/react"; const { useStepper } = defineStepper( { id: "first", title: "First step" }, { id: "second", title: "Second step" }, { id: "last", title: "Last step" } ); const MyStepperComponent = () => { const stepper = useStepper(); const handleSave = () => { stepper.metadata.set("first", { value: "saved" }); }; const meta = stepper.metadata.get("first"); return (

First step: {meta?.value}

); }; ``` -------------------------------- ### Add Stepper with Description (Base UI) Source: https://stepperize.vercel.app/docs/react/shadcn Use this command to add a stepper component that includes descriptions for each step, using Base UI. ```bash npx shadcn add https://stepperize.vercel.app/r/base-ui/stepper-with-description.json ``` -------------------------------- ### Get Namespace Type Utilities Source: https://stepperize.vercel.app/docs/react/api-references/types Illustrates how to use the Get namespace for type inference of step IDs and step types based on a Steps array. ```typescript import { defineStepper, Get } from "@stepperize/react"; const { steps } = defineStepper( { id: "shipping", title: "Shipping" }, { id: "payment", title: "Payment" } ); type StepId = Get.Id; // "shipping" | "payment" type ShippingStep = Get.StepById; // { id: "shipping"; title: string } ``` -------------------------------- ### Use Stepper with Initial Configuration (v5) Source: https://stepperize.vercel.app/docs/react/migration/migrating-to-v5 When migrating to v5, the `useStepper` hook now expects an object with an `initial` property for configuration. This object includes `step`, `metadata`, and `statuses` for the initial state. ```javascript const methods = useStepper({ initial: { step: "first", // The ID of the initial step to display metadata: { ... }, // The initial metadata for each step statuses: { ... }, // The initial status for each step } }); ``` -------------------------------- ### Add Stepper with Description (Radix UI) Source: https://stepperize.vercel.app/docs/react/shadcn Use this command to add a stepper component that includes descriptions for each step, using Radix UI. ```bash npx shadcn add https://stepperize.vercel.app/r/radix-ui/stepper-with-description.json ``` -------------------------------- ### Wrap with Stepper.Root Source: https://stepperize.vercel.app/docs/react/examples/basic Use Stepper.Root to initialize the stepper component with the defined steps. ```javascript {/* ... stepper content ... */} ``` -------------------------------- ### Get Namespace Types Source: https://stepperize.vercel.app/docs/react/api-references/types Utility types for inferring information about steps based on their IDs and the overall Steps type. ```APIDOC ## Get namespace Type| Description ---|--- `Get.Id`| Union of step IDs `Get.StepById`| Step type for given ID `Get.StepSansId`| Union of steps that are not `Id` `Get.Switch`| Object type for `flow.switch` handlers: `{ [Id in Get.Id]?: (step: Get.StepById) => R }` ```typescript import { defineStepper, Get } from "@stepperize/react"; const { steps } = defineStepper( { id: "shipping", title: "Shipping" }, { id: "payment", title: "Payment" } ); type StepId = Get.Id; // "shipping" | "payment" type ShippingStep = Get.StepById; // { id: "shipping"; title: string } ``` ``` -------------------------------- ### useStepper Configuration: Initial State (v5 vs v6) Source: https://stepperize.vercel.app/docs/react/migration/migrating-to-v6 v5 used a nested `initial` object for step, metadata, and statuses. v6 uses top-level `initialStep` and `initialMetadata`, and statuses are derived. ```javascript useStepper({ initial: { step: "second", metadata: { first: { saved: true } }, statuses: { ... }, }, }); ``` ```javascript useStepper({ initialStep: "second", initialMetadata: { first: { saved: true } }, }); ``` -------------------------------- ### Custom Step Indicator with Step Index Source: https://stepperize.vercel.app/docs/react/examples/basic Customize the indicator for each step by providing a render prop to `Stepper.Indicator`. This example shows how to display the step index. ```javascript {({ index }) => {index + 1}} {step.label} ``` -------------------------------- ### Add Stepper with Icons (Base UI) Source: https://stepperize.vercel.app/docs/react/shadcn Use this command to add a stepper component that includes icons for each step, using Base UI. ```bash npx shadcn add https://stepperize.vercel.app/r/base-ui/stepper-with-icon.json ``` -------------------------------- ### Use Stepper Hook Source: https://stepperize.vercel.app/docs/react/api-references/hook Use the useStepper hook to access the stepper instance and its API for state management and navigation. This example shows basic usage within a component. ```javascript import React from "react"; import { defineStepper } from "@stepperize/react"; const { useStepper } = defineStepper( { id: "first", title: "First step" }, { id: "second", title: "Second step" } ); const MyStepperComponent = () => { const stepper = useStepper(); return (

{stepper.state.current.data.title}

); }; ``` -------------------------------- ### Stepper.Next Button Examples Source: https://stepperize.vercel.app/docs/react/api-references/primitives Use Stepper.Next for navigating to the next step. It's automatically disabled on the last step. Dynamic labels and custom click handlers with validation are supported. ```jsx {/* Default behavior */} Next ``` ```jsx {/* Dynamic label */} {stepper.state.isLast ? "Finish" : "Next"} ``` ```jsx {/* Custom click with validation */} { const isValid = await validateCurrentStep(); if (isValid) { stepper.navigation.next(); } }}> Continue ``` -------------------------------- ### Stepper Separator with Dynamic Rendering Source: https://stepperize.vercel.app/docs/react/api-references/primitives Implement Stepper.Separator to visually divide steps. This example shows how to conditionally render the separator between items in a Stepper.List, ensuring the last separator is not displayed. ```jsx {stepper.state.all.map((step, index) => ( ... {index < stepper.state.all.length - 1 && } ))} ``` -------------------------------- ### Configure Initial Step and Metadata Source: https://stepperize.vercel.app/docs/react/examples/scoped Set the initial step and initial metadata for a stepper by passing `initialStep` and `initialMetadata` props to the `Scoped` component. This allows pre-populating state for specific steps. ```javascript import React from "react"; import { defineStepper } from "@stepperize/react"; const { Scoped, useStepper } = defineStepper( { id: "info", title: "Info" }, { id: "review", title: "Review" }, { id: "done", title: "Done" } ); function StepContent() { const stepper = useStepper(); return
{/* content per step */}
; } function StepNavigation() { const stepper = useStepper(); return
{/* buttons */}
; } function Example() { return ( ); } ``` -------------------------------- ### Add Stepper with Icons (Radix UI) Source: https://stepperize.vercel.app/docs/react/shadcn Use this command to add a stepper component that includes icons for each step, using Radix UI. ```bash npx shadcn add https://stepperize.vercel.app/r/radix-ui/stepper-with-icon.json ``` -------------------------------- ### Stepper.Root for Context Provision Source: https://stepperize.vercel.app/docs/react/api-references/scoped Utilize `Stepper.Root` as a convenient wrapper that internally uses `Scoped` to provide stepper context. It accepts `initialStep` and `initialMetadata` for setting initial state, offering an alternative to directly using `Scoped`. ```jsx import React from "react"; import { defineStepper } from "@stepperize/react"; const { Stepper, useStepper } = defineStepper( { id: "first", title: "First" }, { id: "second", title: "Second" } ); export const MyStepper = () => ( {({ stepper }) => (

Current: {stepper.state.current.data.title}

)}
); ```