Guides people through a multi-step flow one step at a time, with a step list, panels and previous/next buttons.
A wizard moves people forward one step at a time and lets them go back to earlier steps. Going back
makes the current step the furthest one again, unless you track progress with completedKeys. To
only show progress without navigation, use a Progress List.
Pass completedKeys to decide when a step is done, for example once its fields are valid. People
can reach every enabled step up to and including the first enabled step after the last completed one, including earlier
steps that are not completed yet. The next button stops there, so compute completedKeys in order,
as the example does. Without completedKeys, every step before the current one counts as completed. Set
allowsSelectingIncompleteSteps to make every enabled step reachable at any time. In that mode no
step counts as completed unless you pass completedKeys.
npx shadcn@latest add @preskok/wizardimport { Button } from "@/components/ui/preskok-ui/button"
import {
Wizard,
WizardButtons,
WizardPanel,
WizardPanels,
WizardStep,
WizardStepList,
} from "@/components/ui/preskok-ui/wizard"
const steps = [
{ id: "account", label: "Account", content: <AccountForm /> },
{ id: "billing", label: "Billing", content: <BillingForm /> },
{ id: "review", label: "Review", content: <Summary /> },
]
export function Signup({ onCreate }: { onCreate: () => void }) {
return (
<Wizard>
<WizardStepList aria-label="Sign up" items={steps}>
{(step) => <WizardStep>{step.label}</WizardStep>}
</WizardStepList>
<WizardPanels items={steps}>
{(step) => <WizardPanel>{step.content}</WizardPanel>}
</WizardPanels>
<WizardButtons
finish={<Button onPress={onCreate}>Create account</Button>}
/>
</Wizard>
)
}WizardButtons renders buttons in the previous and next slots. They move between steps and are
disabled when there is no step to move to. On the last step, finish replaces the next button.
Trailing steps disabled with isDisabled or the Wizard's disabledKeys are skipped when finding
the last step. Panels unmount when their
step is not selected, so keep form values in state above the Wizard. You
can also place your own <Button slot="previous"> and <Button slot="next"> anywhere inside the
Wizard. When Next turns into the finish action on the last step, focus moves to the current step
in the step list.
Each step id must match a WizardPanel id. Steps support isDisabled and description, and
orientation="vertical" puts the step list beside the panels. WizardStateContext exposes the
current, previous and next keys to custom controls.