Navigation

Stepper / Multi-step Form

Numbered steps that split a form into panels, with Back and Next buttons and validation that your code controls.

Class nameTypeDescription
stepperplf:stepperComponentWraps the steps, panels and buttons
stepper-listplf:stepper-listPartThe ordered list of steps
stepper-itemplf:stepper-itemPartA step's list item
stepper-stepplf:stepper-stepPartA step's button
stepper-markerplf:stepper-markerPartThe step's number, written by CSS while it is empty
stepper-contentplf:stepper-contentPartHolds the label and state
stepper-labelplf:stepper-labelPartThe step's name
stepper-stateplf:stepper-statePartThe step's state, in muted text
stepper-panelplf:stepper-panelPartA step's panel
stepper-headingplf:stepper-headingPartThe panel's heading; shows focus
stepper-actionsplf:stepper-actionsPartThe Back and Next row
stepper-backplf:stepper-backPartThe Back button, beside btn
stepper-nextplf:stepper-nextPartThe Next button, beside btn

Default

Author every panel visible and Back and Next hidden: the script hides the inactive panels and shows the buttons, so the whole form shows and submits without JavaScript.

Step 1 of 3

Account information

Workspace details

Review your workspace

Check your details, then create the workspace.

Validation

data-plf-validate makes Next check the step’s fields first and report the first invalid one; going back stays free.

Step 1 of 3

Account information

Workspace details

Review your workspace

Check your details, then create the workspace.

JavaScript

Stepper needs JavaScript. The Full script (pelatform-ui.min.js) starts every component on page load, with no code of your own; with ESM imports, call init() yourself, as in Installation. For markup you add later, see Dynamic content.

<link rel="stylesheet" href="pelatform-ui.min.css">
<script src="pelatform-ui.min.js" defer></script>
<link rel="stylesheet" href="pelatform-ui.prefixed.min.css">
<script src="pelatform-ui.min.js" defer></script>
Attribute Purpose
data-plf-stepper Marks the container
aria-controls On each step’s <button type="button"> in the stepper’s <ol>, its panel’s id; leave it off every step to show the stepper’s own <section>s in order, one per step. The <ol> is named with aria-label or aria-labelledby
aria-current="step" The step shown first; otherwise the first enabled step
disabled A step that cannot be entered; Back and Next stop before it
data-plf-stepper-state-label Optional; filled with the step’s state
data-plf-current-label, data-plf-complete-label, data-plf-upcoming-label, data-plf-disabled-label On the container, the state texts, as for another language; Current step, Completed, Upcoming and Unavailable by default
data-plf-stepper-focus Optional; one per panel, focused after a move; otherwise the panel itself
data-plf-stepper-back, data-plf-stepper-next Optional <button type="button"> controls, authored hidden
<progress> Optional; one directly in the container, whose max, value and aria-valuetext the script sets
data-plf-progress-label On the container, the progress text; {index} is the current step and {count} the number of steps, Step {index} of {count} by default
data-plf-validate On the container: moving forward first checks the current step’s fields and reports the first invalid one, as the browser does on submit; going back stays free
data-plf-stepper-step, data-plf-stepper-panel Optional; mark the steps and panels, which are otherwise the <ol>’s buttons and the stepper’s <section>s or their aria-controls targets

People can return to any step they have reached; steps further ahead get aria-disabled="true".

Methods

Method Behavior
PLF.Stepper.getOrCreateInstance(element, options) Returns the instance, creating it for valid markup; options.active names the panel to show first
PLF.Stepper.getInstance(element) Returns the instance or null
instance.getState() Returns {panelId, index, total, furthestIndex}; indexes are zero-based
instance.next(options), instance.previous(options) Move one step
instance.select(panelId, options) Shows the step of the panel with this id, which you write on a panel you select from code: a reached step or the step after the furthest one
instance.refresh() Updates steps and buttons after you change disabled
instance.destroy() Removes listeners and restores the markup, so every panel shows; values stay

Methods move focus only with {focus: true}, and return false when the move is canceled, unchanged, disabled or out of reach.

Events

Event When
plf:stepper:before-change Before another step shows; cancelable, except with reason validation
plf:stepper:change After the new step shows

Each event’s detail:

Property Value
instance The Stepper instance
previousPanelId The id of the panel shown before the move
panelId The id of the panel the move goes to
previousIndex The zero-based position of the step shown before the move
index The zero-based position of the step the move goes to
reason api, trigger or validation
trigger The step, Back or Next button, the invalid field for validation, or null from a method

A validation move shows the panel of an invalid field on native submit; resetting the form shows the first step again without events.

Keyboard

Key Action
Tab, Shift+Tab Move between steps, the panel’s fields and the Back and Next buttons
Enter, Space Activates the focused step or button

React

Stepper from @pelatform/react renders this stepper: it keeps its own step, or the application sets it with value, and each part is a component of its own.

Prop Values Default
value The step shown, from 0, which the application changes in onValueChange; keeping it refuses the move, as the Validation example does Its own state
defaultValue The step shown first when the application does not set value The first enabled step
onValueChange (value), called when a step, Back, Next, an invalid field on submit or a form reset asks for another step None
currentLabel, completeLabel, upcomingLabel, disabledLabel The state texts in StepperState Current step, Completed, Upcoming and Unavailable
progressLabel (step, count), the progress text, with the step’s number from 1 Step {step} of {count}

The parts:

Part Element
StepperList An ol with stepper-list, named with aria-label
StepperItem An li with stepper-item
StepperStep A button with stepper-step, which shows its panel once reached; disabled keeps the step from being entered
StepperMarker A span with stepper-marker
StepperContent A span with stepper-content
StepperLabel A span with stepper-label
StepperState A span with stepper-state, holding the step’s state text
StepperProgress A progress with progress, whose value is the step’s number
StepperPanel A section with stepper-panel, one per step in order
StepperHeading An h3 with stepper-heading, which takes the focus after a move; level sets 2 to 6
StepperActions A div with stepper-actions
StepperBack, StepperNext A button with btn btn-outline stepper-back or btn btn-primary stepper-next, labeled Back or Next unless given children; color and variant give another look

The other props are the element’s own, className and ref included.

Variable Default
--plf-stepper-gap Space 4 (16px); Space 3 (12px) between steps
--plf-stepper-color Text
--plf-stepper-bg Transparent, on steps and panels
--plf-stepper-border --plf-color-border-subtle; primary on the current step unless set
--plf-stepper-radius Large radius (8px)
--plf-stepper-marker-size 2rem
--plf-stepper-marker-bg, --plf-stepper-marker-color Muted; primary when current, primary subtle when completed
--plf-stepper-panel-padding Space 4 (16px)

Built with Pelatform UIv0.1.0

Components

Getting started

Foundations

Components

Actions

Data display

Navigation

Feedback

Data input

Layout

Advanced

Integrations

Blocks

Application

Authentication

Icons