AsterUIDocsv1.0.2

Docs / Component reference

Stepper & yield* runWizard()

Show which step is current and which steps remain. The generator helper can take the caller through the sequence.

Stepper example

Install

sh
npx @fierst/ui@1.0.2 add stepper

Registry dependencies: theme, icon, button. Package dependencies: @lucide/icons.

Exports from ./ui/stepper: StepItem, Stepper, WizardStepDef, runWizard.

Download the registry source for stepper 1.0.2.

API contracts

ts
export interface StepItem {
  id: string;
  title: string;
  description?: string;
}

export function Stepper({
  steps,
  currentStep,
  onStepClick,
  class: extraClass,
}: {
  steps: readonly StepItem[];
  currentStep: number;
  onStepClick?: (index: number) => void;
  class?: string;
})

export interface WizardStepDef<TState> {
  id: string;
  title: string;
  description?: string;
  render: (state: TState, update: (patch: Partial<TState>) => void) => View;
  canProceed?: (state: TState) => boolean;
}

export function* runWizard<TState extends Record<string, any>>(
  steps: readonly WizardStepDef<TState>[],
  initial: TState,
  opts: { finishLabel?: string; cancelLabel?: string } = {},
): Generator<View, TState | null, any>