WlStepper
Appearance
Bind the current index and put each step’s fields in the panel slot. The application decides when Next is available and what a transition does.
Full example
<script setup lang="ts">
import { WlField, WlInput, type WlStepItem, WlStepper } from "legato-ui";
import { computed, ref } from "vue";
const props = { preview: {} as Record<string, unknown> };
const current = ref(0);
const name = ref("");
const canAdvance = computed(() => Boolean(name.value.trim()) && props.preview?.canGoNext !== false);
const forwardedPreview = computed(() => {
const attributes = { ...props.preview };
delete attributes.canGoNext;
return attributes;
});
const items = computed<readonly WlStepItem[]>(() => [
{ key: "workspace", label: "Workspace" },
{ key: "review", label: "Review", disabled: current.value === 0 && !canAdvance.value }
]);
</script>
<template>
<WlStepper
v-model:current="current"
:items="items"
:can-go-next="canAdvance"
clickable
v-bind="forwardedPreview"
>
<template #default="{ index }">
<WlField
v-if="index === 0"
v-slot="{ id, ariaDescribedby }"
label="Workspace name"
hint="Enter a workspace name to continue to Review."
required
>
<WlInput
:id="id"
v-model="name"
:aria-describedby="ariaDescribedby"
required
/>
</WlField>
<p v-else class="wl-text-body">{{ name }}</p>
</template>
</WlStepper>
</template>Behavior
Full example
<script setup lang="ts">
import { WlField, WlInput, type WlStepItem, WlStepper } from "legato-ui";
import { computed, ref } from "vue";
const props = { preview: {} as Record<string, unknown> };
const current = ref(0);
const name = ref("");
const canAdvance = computed(() => Boolean(name.value.trim()) && props.preview?.canGoNext !== false);
const forwardedPreview = computed(() => {
const attributes = { ...props.preview };
delete attributes.canGoNext;
return attributes;
});
const items = computed<readonly WlStepItem[]>(() => [
{ key: "workspace", label: "Workspace" },
{ key: "review", label: "Review", disabled: current.value === 0 && !canAdvance.value }
]);
</script>
<template>
<WlStepper
v-model:current="current"
:items="items"
:can-go-next="canAdvance"
clickable
v-bind="forwardedPreview"
>
<template #default="{ index }">
<WlField
v-if="index === 0"
v-slot="{ id, ariaDescribedby }"
label="Workspace name"
hint="Enter a workspace name to continue to Review."
required
>
<WlInput
:id="id"
v-model="name"
:aria-describedby="ariaDescribedby"
required
/>
</WlField>
<p v-else class="wl-text-body">{{ name }}</p>
</template>
</WlStepper>
</template>Custom step actions
Confirm access, review the setting, then save. The actions slot supplies the enabled Back and Next callbacks.
- 1Workspace accessCurrent step
- 2Review
Full example
<script setup lang="ts">
import { WlButton, WlCheckbox, type WlStepItem, WlStepper } from "legato-ui";
import { computed, ref } from "vue";
const current = ref(0);
const confirmed = ref(false);
const saved = ref(false);
const items = computed<readonly WlStepItem[]>(() => [
{ key: "access", label: "Workspace access" },
{ key: "review", label: "Review" }
]);
</script>
<template>
<div class="wl-stack" data-space="sm">
<WlStepper
v-model:current="current"
:items="items"
:can-go-next="confirmed"
orientation="vertical"
>
<template #default="{ index }">
<WlCheckbox v-if="index === 0" v-model="confirmed">{{ "Allow the team to open this workspace" }}</WlCheckbox>
<p v-else>{{ "The team can open the workspace after you save." }}</p>
</template>
<template #actions="{ canGoBack, canGoNext, back, next }">
<WlButton v-if="canGoBack" @click="back">{{ "Edit access" }}</WlButton>
<WlButton
v-if="current === 0"
variant="primary"
:disabled="!canGoNext"
@click="next"
>
{{ "Review access" }}
</WlButton>
<WlButton v-else variant="primary" @click="saved = true">{{ "Save" }}</WlButton>
</template>
</WlStepper>
<output v-if="saved" aria-label="Changes saved">{{ "Changes saved" }}</output>
</div>
</template>Props
Types, accepted values and literal defaults come from the public manifest. Inherited settings name their source; “Not set” means no default is declared.
v-model:current: numberZero-based index of the current step and panel.
| Prop | Type / values | Default | Purpose |
|---|---|---|---|
items * | readonly WlStepItem[] | Required | Ordered step descriptors. |
clickable | boolean | Not set | Allow activating a step directly through the step list. |
orientation | "horizontal" | | "horizontal" | Direction of the step list and its arrow-key navigation. |
canGoBack | boolean | true | Allow the default Back action. |
canGoNext | boolean | true | Allow the default Next action. Applications own validation. |
pt | WlPt< | Not set | Attributes for the wrapper, steps, panel and actions. |
Events
| Event | Payload | When emitted |
|---|---|---|
update:current | number | The zero-based index requested by a step or navigation action. |
Slots
| Slot | Type / values | Content |
|---|---|---|
default | default?(props: WlStepperPanelSlotProps): unknown; | Current panel content. |
actions | actions?(props: WlStepperActionsSlotProps): unknown; | Replace the built-in transitions with application actions. |
Pass-through: pt
Sections WlStepper are listed below. Attributes merge in this order: createWlPt() WlConfig.ptpt instance. Class and style merge; the last supplied value takes priority for other attributes.
| Section | DOM | Purpose |
|---|---|---|
root | div.wl-step-flow | Main element of the component. |
steps | ol.wl-steps | Ordered list of steps. |
panel | div.wl-step-flow__panel | Panel that contains the current content. |
actions | div.wl-step-flow__actions | Container for transition actions. |
Sections refer to the component DOM. Dotted names identify a configuration group and its section; composite parts use their own pt groups. Global and local attributes merge, with class and style added together.
Keyboard and accessibility
- Bind the current index and put each step’s fields in the panel slot. The application decides when Next is available and what a transition does.
- Give each step a name that identifies the task in the current panel.
- When direct step selection is enabled, keep the step-list arrow keys available and use Tab to reach controls in the panel.
Keyboard and application responsibilities
Provide a meaningful accessible name and connect labels, hints and errors to the focusable element. Check the behavior with your own data and a screen reader.
WAI-ARIA Authoring PracticesChanges are emitted through v-model:current. After selection, cancellation and reset, labels and states must remain clear.
In your application, check keyboard controls, zoom and focus visibility. State labels and required information must be readable in every theme.