Skip to content

Stepper

The Stepper component displays a sequence of steps, highlighting the current step and marking completed steps. It’s useful for multi-step processes like wizards, forms, or checkout flows.

No additional dependencies required.

<div data-role="stepper" data-steps="5" data-step="2"></div>
<!-- Circular steps with step 2 active -->
<div data-role="stepper" data-view="cycle" data-step="2"></div>
<!-- Diamond-shaped steps with step 3 active -->
<div data-role="stepper" data-view="diamond" data-step="3"></div>
<!-- Vertical stepper -->
<div data-role="stepper" class="vertical" data-steps="5"></div>
<!-- Interactive stepper (clickable steps) -->
<div data-role="stepper" data-steps="4" data-step="1" data-step-click="true"></div>
ParameterTypeDefaultDescription
stepperDeferrednumber0Deferred initialization time in milliseconds
viewstring”square”Visual style of the stepper: “square”, “cycle”, or “diamond”
stepsnumber3Number of steps to display
stepnumber1Initial active step
stepClickbooleanfalseWhether clicking on a step changes the active step
clsStepperstring""Additional CSS class for the stepper container
clsStepstring""Additional CSS class for each step
clsCompletestring""Additional CSS class for completed steps
clsCurrentstring""Additional CSS class for the current step
  • next() - Moves to the next step.
  • prev() - Moves to the previous step.
  • first() - Moves to the first step.
  • last() - Moves to the last step.
  • toStep(step) - Moves to a specific step.
const stepper = Metro.getPlugin('#myStepper', 'stepper');
// Move to the next step
stepper.next();
// Move to the previous step
stepper.prev();
// Move to the first step
stepper.first();
// Move to the last step
stepper.last();
// Move to step 3
stepper.toStep(3);
EventDescription
onStepTriggered when the active step changes
onStepClickTriggered when a step is clicked
onStepperCreateTriggered when the stepper is created
VariableDefault (Light)Dark ModeDescription
—stepper-step-background#515151#515151Background color of the step
—stepper-step-color#FFFFFF#FFFFFFText color of the step
—stepper-step-background-complete#00B500#00B500Background color of completed steps
—stepper-step-color-complete#FFFFFF#FFFFFFText color of completed steps
—stepper-step-background-current#94B6FF#94B6FFBackground color of the current step
—stepper-step-color-current#FFFFFF#FFFFFFText color of the current step
—stepper-line-color#e3e3e3#2b2d30Color of the line connecting the steps
#my-stepper {
--stepper-step-background: #757575;
--stepper-step-color: #ffffff;
--stepper-step-background-complete: #4caf50;
--stepper-step-color-complete: #ffffff;
--stepper-step-background-current: #2196f3;
--stepper-step-color-current: #ffffff;
--stepper-line-color: #e0e0e0;
}
  • .stepper - Main container class (automatically added)
  • .stepper.vertical - For vertical orientation
  • .step - Individual step element
  • .step.complete - Completed step
  • .step.current - Current step
  • .stepper.cycle - For circular steps
  • .stepper.diamond - For diamond-shaped steps
<div data-role="stepper" data-steps="5" data-step="2"></div>
<div data-role="stepper" data-steps="4" data-step="1" data-step-click="true"></div>
<div data-role="stepper"
data-steps="3"
data-cls-stepper="custom-stepper"
data-cls-step="custom-step"
data-cls-complete="custom-complete"
data-cls-current="custom-current">
</div>
// Initialize the stepper
const element = document.getElementById('myStepper');
Metro.makePlugin(element, 'stepper', {
steps: 5,
step: 1,
view: 'cycle',
stepClick: true
});
// Get the stepper instance
const stepper = Metro.getPlugin('#myStepper', 'stepper');
// Add navigation buttons
document.getElementById('nextBtn').addEventListener('click', () => {
stepper.next();
});
document.getElementById('prevBtn').addEventListener('click', () => {
stepper.prev();
});