Steps
Display the completed, current and upcoming stages of a process. Each stage is an HuiStepItem.
Use Steps for progress display or when you manage page content yourself. Use Stepper for content panels, previous/next actions, validation and linear navigation. Stepper renders its progress bar with Steps, sharing the base appearance while providing a guided workflow.
Import
import { HuiSteps, HuiStepItem } from '@nscode/handy-ui'
Internal state and controlled updates
Omitted active, including with an update listener only, stores the current step internally from zero. A passed prop, including undefined, is controlled; undefined displays as zero. Rejected updates retain the parent state and the same active step emits no value events.
<script setup lang="ts">
import { ref } from 'vue'
import { HuiSteps, HuiStepItem, HuiButton, HuiSpace } from '@nscode/handy-ui'
const q1Redraw = ref(0)
const q1Last = ref('No request')
const q1Model = ref(0)
</script>
<template>
<div class="steps-q1-demo">
<HuiButton class="q1-redraw" @click="q1Redraw++">Parent redraw {{ q1Redraw }}</HuiButton>
<HuiSpace direction="vertical" fill>
<div>
<p>Omitted prop: internal state</p>
<div class="q1-local">
<HuiSteps clickable
><HuiStepItem title="First" /><HuiStepItem title="Second" /><HuiStepItem
title="Third"
disabled
/></HuiSteps>
</div>
</div>
<div>
<p>Update listener only: internal state</p>
<div class="q1-listener">
<HuiSteps clickable @update:active="q1Last = JSON.stringify($event)"
><HuiStepItem title="First" /><HuiStepItem title="Second" /><HuiStepItem
title="Third"
disabled
/></HuiSteps>
</div>
</div>
<div>
<p>Explicit undefined: controlled</p>
<div class="q1-empty">
<HuiSteps clickable :active="undefined"
><HuiStepItem title="First" /><HuiStepItem title="Second" /><HuiStepItem
title="Third"
disabled
/></HuiSteps>
</div>
</div>
<div>
<p>Fixed controlled value: parent rejects</p>
<div class="q1-fixed">
<HuiSteps clickable :active="1" @update:active="q1Last = JSON.stringify($event)"
><HuiStepItem title="First" /><HuiStepItem title="Second" /><HuiStepItem
title="Third"
disabled
/></HuiSteps>
</div>
</div>
<div>
<p>Two-way binding</p>
<div class="q1-bound">
<HuiSteps clickable v-model:active="q1Model"
><HuiStepItem title="First" /><HuiStepItem title="Second" /><HuiStepItem
title="Third"
disabled
/></HuiSteps>
</div>
</div>
<p class="q1-notification">Bound value: {{ q1Model }}; latest request: {{ q1Last }}</p>
</HuiSpace>
</div>
</template>
Basic usage
active is a zero-based index. A stage before it is finished, the stage at it is in progress, and later stages are waiting. Setting active to the number of stages marks them all as finished.
<script setup lang="ts">
import { ref } from 'vue'
import { HuiButton, HuiSpace, HuiStepItem, HuiSteps } from '@nscode/handy-ui'
const active = ref(0)
</script>
<template>
<HuiSpace direction="vertical" fill>
<HuiSteps :active="active">
<HuiStepItem title="Information" description="Enter your details" />
<HuiStepItem title="Verification" description="Verify your identity" />
<HuiStepItem title="Complete" />
</HuiSteps>
<HuiSpace>
<HuiButton :disabled="active === 0" @click="active--">Previous</HuiButton>
<HuiButton type="primary" @click="active = active >= 3 ? 0 : active + 1">Next</HuiButton>
<span>active = {{ active }}</span>
</HuiSpace>
</HuiSpace>
</template>
Two-way binding and disabled stages
With clickable, selecting another enabled stage emits update:active followed by change. Use v-model:active to receive the new index. A disabled stage ignores clicks, Enter and Space, and is excluded from the Tab order.
This example only allows selecting stages already reached. Click Next to unlock later stages; after returning to an earlier stage, stages previously reached remain available.
<script setup lang="ts">
import { ref } from 'vue'
import { HuiButton, HuiSpace, HuiStepItem, HuiSteps } from '@nscode/handy-ui'
const titles = ['Information', 'Contact details', 'Submit']
const active = ref(0)
const maxReached = ref(0)
const lastChange = ref('No selection yet')
const next = () => {
active.value = Math.min(active.value + 1, titles.length - 1)
maxReached.value = Math.max(maxReached.value, active.value)
}
const onChange = (index: number) => {
lastChange.value = `change: ${index}`
}
</script>
<template>
<HuiSpace direction="vertical" fill>
<HuiSteps v-model:active="active" clickable @change="onChange">
<HuiStepItem
v-for="(title, index) in titles"
:key="title"
:title="title"
:disabled="index > maxReached"
/>
</HuiSteps>
<HuiSpace>
<HuiButton type="primary" :disabled="active === titles.length - 1" @click="next">
Next
</HuiButton>
<span>Current: {{ active }}; reached: {{ maxReached }}</span>
</HuiSpace>
<span>{{ lastChange }}</span>
</HuiSpace>
</template>
Selecting the current stage does not emit either event. Changing active externally updates the display without emitting selection events. Disabled stages retain their status colors.
Direction, alignment and simple style
direction supports horizontal and vertical. align-center centers each horizontal stage. simple uses smaller filled status circles and a background for the steps bar.
<script setup lang="ts">
import { HuiSpace, HuiStepItem, HuiSteps } from '@nscode/handy-ui'
</script>
<template>
<HuiSpace direction="vertical" fill size="large">
<div>
<p>horizontal</p>
<HuiSteps :active="1" direction="horizontal">
<HuiStepItem title="Apply" />
<HuiStepItem title="Review" />
<HuiStepItem title="Complete" />
</HuiSteps>
</div>
<div>
<p>align-center</p>
<HuiSteps :active="1" align-center>
<HuiStepItem title="Apply" />
<HuiStepItem title="Review" />
<HuiStepItem title="Complete" />
</HuiSteps>
</div>
<div>
<p>simple</p>
<HuiSteps :active="1" simple>
<HuiStepItem title="Apply" />
<HuiStepItem title="Review" />
<HuiStepItem title="Complete" />
</HuiSteps>
</div>
<div>
<p>vertical</p>
<HuiSteps :active="1" direction="vertical">
<HuiStepItem title="Apply" description="Application received" />
<HuiStepItem title="Review" description="Awaiting approval" />
<HuiStepItem title="Complete" />
</HuiSteps>
</div>
</HuiSpace>
</template>
Stage size
space sets each stage's width horizontally or height vertically. Numbers are pixels; strings are CSS lengths. The last stage is sized by its content.
<script setup lang="ts">
import { HuiSpace, HuiStepItem, HuiSteps } from '@nscode/handy-ui'
</script>
<template>
<HuiSpace direction="vertical" fill size="large">
<HuiSteps :active="1" :space="160">
<HuiStepItem title="160px" />
<HuiStepItem title="160px" />
<HuiStepItem title="Complete" />
</HuiSteps>
<HuiSteps :active="1" space="25%">
<HuiStepItem title="25%" />
<HuiStepItem title="25%" />
<HuiStepItem title="Complete" />
</HuiSteps>
<HuiSteps :active="1" direction="vertical" space="80px">
<HuiStepItem title="80px" />
<HuiStepItem title="80px" />
<HuiStepItem title="Complete" />
</HuiSteps>
</HuiSpace>
</template>
Status
Each stage supports wait, process, finish, error and success. Set a stage's status to override the value inferred from active. Set finish-status or process-status on the steps bar to change the default status of completed or current stages.
<script setup lang="ts">
import { ref } from 'vue'
import { HuiRadio, HuiRadioGroup, HuiSpace, HuiStepItem, HuiSteps } from '@nscode/handy-ui'
import type { StepsStatus } from '@nscode/handy-ui'
const statuses: StepsStatus[] = ['wait', 'process', 'finish', 'error', 'success']
const finishStatus = ref<StepsStatus>('finish')
const processStatus = ref<StepsStatus>('process')
</script>
<template>
<HuiSpace direction="vertical" fill>
<HuiSteps>
<HuiStepItem v-for="status in statuses" :key="status" :title="status" :status="status" />
</HuiSteps>
<HuiSpace>
<span>finish-status</span>
<HuiRadioGroup v-model="finishStatus" type="button">
<HuiRadio v-for="status in statuses" :key="status" :value="status">{{ status }}</HuiRadio>
</HuiRadioGroup>
</HuiSpace>
<HuiSpace>
<span>process-status</span>
<HuiRadioGroup v-model="processStatus" type="button">
<HuiRadio v-for="status in statuses" :key="status" :value="status">{{ status }}</HuiRadio>
</HuiRadioGroup>
</HuiSpace>
<HuiSteps :active="1" :finish-status="finishStatus" :process-status="processStatus">
<HuiStepItem title="Completed" />
<HuiStepItem title="Current" />
<HuiStepItem title="Upcoming" />
</HuiSteps>
</HuiSpace>
</template>
Icons and slots
icon accepts an icon name or VNode. The icon, title and description slots provide more control.
<script setup lang="ts">
import { h } from 'vue'
import { HuiIcon, HuiStepItem, HuiSteps } from '@nscode/handy-ui'
const star = h(HuiIcon, { name: 'star' })
</script>
<template>
<HuiSteps :active="1">
<HuiStepItem title="Account" icon="user" />
<HuiStepItem :icon="star">
<template #title><strong>Review</strong></template>
<template #description>Awaiting approval</template>
</HuiStepItem>
<HuiStepItem title="Submit">
<template #icon><HuiIcon name="upload" /></template>
</HuiStepItem>
</HuiSteps>
</template>
Read stage information
The component ref exposes steps in DOM order and the current active. These values are read-only.
<script setup lang="ts">
import { ref } from 'vue'
import { HuiButton, HuiSpace, HuiStepItem, HuiSteps } from '@nscode/handy-ui'
const stepsRef = ref<InstanceType<typeof HuiSteps>>()
const information = ref('')
const read = () => {
const stages = stepsRef.value?.steps ?? []
information.value = `${stages.map((stage) => stage.title).join(', ')}; active: ${stepsRef.value?.active}`
}
</script>
<template>
<HuiSpace direction="vertical" fill>
<HuiSteps ref="stepsRef" :active="1">
<HuiStepItem title="Apply" />
<HuiStepItem title="Review" />
<HuiStepItem title="Complete" />
</HuiSteps>
<HuiSpace>
<HuiButton @click="read">Read stages</HuiButton>
<span>{{ information }}</span>
</HuiSpace>
</HuiSpace>
</template>
HuiSteps Props
| Prop | Type | Default | Description |
|---|---|---|---|
| active / v-model:active | number | undefined | Zero-based current stage index; supports two-way binding |
| space | number | string | — | Width horizontally or height vertically; numbers are pixels; excludes the last stage |
| direction | 'horizontal' | 'vertical' | 'horizontal' | Layout direction |
| alignCenter | boolean | false | Center each horizontal stage |
| simple | boolean | false | Use a compact style with filled status circles |
| finishStatus | StepsStatus | 'finish' | Status of completed stages |
| processStatus | StepsStatus | 'process' | Status of the current stage |
| clickable | boolean | false | Enable mouse and keyboard selection of enabled stages |
HuiStepItem Props
| Prop | Type | Default | Description |
|---|---|---|---|
| title | string | '' | Stage title; overridden by its slot |
| description | string | '' | Stage description; overridden by its slot |
| icon | string | VNode | — | Icon name or VNode, replacing the default number or status icon |
| status | StepsStatus | — | Override the status inferred from active |
| disabled | boolean | false | Ignore clicks, Enter and Space, and exclude this stage from the Tab order |
Events
| Event | Parameters | Description |
|---|---|---|
| update:active | (index: number) | Select another enabled stage while clickable; supports v-model:active |
| change | (index: number) | Emitted after update:active for the same selection |
Slots
| Component | Slot | Description |
|---|---|---|
| HuiSteps | default | HuiStepItem components |
| HuiStepItem | title | Custom title |
| HuiStepItem | description | Custom description |
| HuiStepItem | icon | Custom icon |
HuiStepItem has no default slot.
Exposed properties
| Property | Type | Description |
|---|---|---|
| steps | StepItemInstance[] | Current stages in DOM order |
| active | number | Actual current index: parent value when controlled, internal state otherwise |
Types
import type {
StepsProps,
StepItemProps,
StepsDirection,
StepsStatus,
StepItemInstance,
StepsContext
} from '@nscode/handy-ui'
import type { VNode } from 'vue'
type StepsDirection = 'horizontal' | 'vertical'
type StepsStatus = 'wait' | 'process' | 'finish' | 'error' | 'success'
interface StepItemInstance {
uid: number
getEl: () => HTMLElement | undefined
readonly title: string
readonly description: string
readonly icon: string | VNode | undefined
readonly status: StepsStatus | undefined
readonly disabled: boolean
}
STEPS_INJECTION_KEY is also exported for custom child components that integrate with HuiSteps.