Skip to content

ProStepForm

Overview

ProStepForm is a step form component that encapsulates a-steps + step content + navigation buttons. Each step's content is provided via named slots, supporting async validation and draft save scenarios.

Basic Usage

vue
<script setup lang="ts">
import { ref } from 'vue'
import ProStepForm from '@/components/Pro/ProStepForm/index.vue'
import type { ProStepFormStep } from '@/types/pro'

const currentStep = ref(0)

const steps: ProStepFormStep[] = [
  { title: 'Basic Info' },
  { title: 'Configuration' },
  { title: 'Confirm' },
]

const handleNext = async (step: number) => {
  // Validate current step here
  currentStep.value = step + 1
}

const handleSubmit = () => {
  console.log('Submit form')
}
</script>

<template>
  <ProStepForm
    v-model="currentStep"
    :steps="steps"
    @next="handleNext"
    @submit="handleSubmit"
  >
    <template #step-0>
      <p>Step 1 content</p>
    </template>
    <template #step-1>
      <p>Step 2 content</p>
    </template>
    <template #step-2>
      <p>Step 3 content</p>
    </template>
  </ProStepForm>
</template>

Props

PropTypeDefaultDescription
stepsProStepFormStep[]Step configuration
modelValuenumber0Current step index (v-model)
loadingbooleanfalseButton loading state
prevTextstring'Previous'Previous button text
nextTextstring'Next'Next button text
submitTextstring'Submit'Submit button text

ProStepFormStep

typescript
interface ProStepFormStep {
  title: string
  description?: string
  icon?: Component
}

Events

EventParamsDescription
update:modelValue(step: number)Step changed
next(currentStep: number)Next clicked, advance step manually after validation
prev(currentStep: number)Previous clicked
submitSubmit clicked

Slots

SlotDescription
step-{index}Content for step at index
extra-actionsExtra action buttons (e.g. save draft, reset)

Methods (via ref)

MethodDescription
prev()Go to previous step
goTo(step)Jump to a specific step

MITライセンスの下で公開されています