Overview
A stepper is a .nds-stepper of .nds-stepper-step items. Each step has a base with a numbered circle, and content with a title and a description. The script marks each step completed, current or upcoming from the stepper’s data-current, and the line between two circles takes the color of that state. A radial stepper shows only the current step, beside a ring that fills as the user moves on. A static stepper shows an order with no progress, such as a how-it-works row.
Pick another component when:
- the progress is a percentage, or has no fixed steps: Progress
- the user opens the parts in any order: Tabs
- the user pages through one long list: Pagination
- the steps are dated events, such as a request’s history: Timeline
Markup
Variants
Most classes go on .nds-stepper. The Card rows put nds-card on the stepper, on every step or on every step’s content, as the On element cell says. The Action rows act on the second step, which is the current step in the canon. The Layout row sets the desktop layout. Phone layout and Tablet layout each add a breakpoint class, which wins on that screen size. The ring and the .nds-stepper-next lines show only in the radial layout: leave them out of a stepper that is never radial. An option that needs one layout has a row for each class that gives it. A Divider choice has one row for each step: write a divider at the start of every step’s content. The Icons choice works the same way: write an icon in every circle. A size class gives a different size in the radial layout, as its Use cell says.
| Group | Option | Markup | On element | Use |
|---|---|---|---|---|
| Layout | Horizontal (default) | — | — | The steps in a row, start to end. Every title must fit its column |
| Layout | Vertical | .nds-vertical |
.nds-stepper |
The steps in a column. For a step with long content or buttons, or a narrow column |
| Layout | Radial (hint: The current step only, beside a progress ring) | .nds-radial |
.nds-stepper:not(.nds-static) |
The current step only, beside the ring. For a narrow space, such as a side column |
| Alternate | Alternate (hint: Vertical: the line in the middle, the steps on both sides. Desktop only) | .nds-alternate |
.nds-stepper.nds-vertical:not(.nds-card) |
On a desktop, the line runs down the middle and the steps take turns on each side. Tablets and phones keep one side. For a page-wide Timeline |
| Phone layout | Same (default) (hint: Uses the Layout choice) | — | — | The Layout choice on phones: narrower than 600px |
| Phone layout | Horizontal | .nds-horizontal-sm |
.nds-stepper.nds-vertical |
A row on phones: narrower than 600px |
| Phone layout | Horizontal | .nds-horizontal-sm |
.nds-stepper.nds-radial |
A row on phones: narrower than 600px |
| Phone layout | Vertical | .nds-vertical-sm |
.nds-stepper:not(.nds-vertical) |
A column on phones: narrower than 600px |
| Phone layout | Radial | .nds-radial-sm |
.nds-stepper:not(.nds-radial):not(.nds-static) |
The ring on phones: narrower than 600px |
| Tablet layout | Same (default) (hint: Uses the Layout choice) | — | — | The Layout choice on tablets: 600px to 959px |
| Tablet layout | Horizontal | .nds-horizontal-md |
.nds-stepper.nds-vertical |
A row on tablets: 600px to 959px |
| Tablet layout | Horizontal | .nds-horizontal-md |
.nds-stepper.nds-radial |
A row on tablets: 600px to 959px |
| Tablet layout | Vertical | .nds-vertical-md |
.nds-stepper:not(.nds-vertical) |
A column on tablets: 600px to 959px |
| Tablet layout | Radial | .nds-radial-md |
.nds-stepper:not(.nds-radial):not(.nds-static) |
The ring on tablets: 600px to 959px |
| Size | XS | .nds-xs |
.nds-stepper.nds-radial |
A 40px ring with smaller text. Radial only |
| Size | XS | .nds-xs |
.nds-stepper.nds-radial-sm |
A 40px ring with smaller text. Radial only |
| Size | XS | .nds-xs |
.nds-stepper.nds-radial-md |
A 40px ring with smaller text. Radial only |
| Size | SM | .nds-sm |
.nds-stepper.nds-radial |
A 48px ring with smaller text. Radial only |
| Size | SM | .nds-sm |
.nds-stepper.nds-radial-sm |
A 48px ring with smaller text. Radial only |
| Size | SM | .nds-sm |
.nds-stepper.nds-radial-md |
A 48px ring with smaller text. Radial only |
| Size | MD (default) | — | — | 32px circles, or a 64px ring in the radial layout |
| Size | LG | .nds-lg |
.nds-stepper:not(.nds-dot) |
40px circles, or an 80px ring |
| Size | XL | .nds-xl |
.nds-stepper:not(.nds-dot) |
48px circles, or a 120px ring with a larger title |
| Dot | Dot (hint: Small dots with no numbers. Not radial) | .nds-dot |
.nds-stepper:not(.nds-lg):not(.nds-xl):not(.nds-radial):not(.nds-icons) |
16px dots with no numbers. For a short flow where the order is plain, or a Timeline. A dot has one size, and the radial layout shows no dots |
| Icons | Icons (hint: An icon in each circle in place of the number. Not with Dot) | .nds-icons |
.nds-stepper:not(.nds-dot) |
An icon in each circle in place of the number. A completed step shows a check mark in place of its icon. Not with Dot. See Icons under Behavior |
| Icons | Icons (hint: An icon in each circle in place of the number. Not with Dot) | canon #stepper-icon-1 |
.nds-stepper-step:nth-child(2) .nds-stepper-circle |
The icon of step 1 |
| Icons | Icons (hint: An icon in each circle in place of the number. Not with Dot) | canon #stepper-icon-2 |
.nds-stepper-step:nth-child(3) .nds-stepper-circle |
The icon of step 2 |
| Icons | Icons (hint: An icon in each circle in place of the number. Not with Dot) | canon #stepper-icon-3 |
.nds-stepper-step:nth-child(4) .nds-stepper-circle |
The icon of step 3 |
| Icons | Icons (hint: An icon in each circle in place of the number. Not with Dot) | canon #stepper-icon-4 |
.nds-stepper-step:nth-child(5) .nds-stepper-circle |
The icon of step 4 |
| Type | Progress (default) (hint: Steps done, current and to come) | [data-current="2"] |
.nds-stepper |
The script marks each step completed, current or upcoming from data-current. For a flow the user moves through |
| Type | Static (hint: Every step looks the same, with no progress. Not radial) (demo: + icon-circle) (demo: + icon-outline) | .nds-static |
.nds-stepper:not(.nds-radial):not(.nds-radial-sm):not(.nds-radial-md) |
Every step looks the same, and the line is neutral. For an order with no progress, such as a how-it-works row. Not radial, which needs a current step. See Static under Behavior |
| Type | Static (hint: Every step looks the same, with no progress. Not radial) (demo: + icon-circle) (demo: + icon-outline) | .nds-featured-icon |
.nds-stepper:not(.nds-dot) .nds-stepper-circle |
Every circle is a Featured Icon. Write nds-circle nds-outline too, and change them in the Icon rows. A dot takes no featured icon classes |
| On color | On color (hint: For a dark or brand background) | .nds-oncolor |
.nds-stepper |
Light circles, lines and text, for a dark or brand background. Inside an on-color area (data-theme="dark oncolor"), the stepper already takes this look: skip the class |
| Icon shape | Rounded (default) (hint: A rounded square) | — | .nds-stepper-circle.nds-featured-icon |
A rounded square |
| Icon shape | Circle (hint: A round icon) (id: icon-circle) | .nds-circle |
.nds-stepper-circle.nds-featured-icon |
A round icon |
| Icon style | Light (default) (hint: A light fill in the icon color) | — | .nds-stepper-circle.nds-featured-icon |
A light fill in the icon color |
| Icon style | Outline (hint: No fill and a border in the icon color) (id: icon-outline) | .nds-outline |
.nds-stepper-circle.nds-featured-icon |
No fill and a border in the icon color |
| Icon style | Dark (hint: A solid fill and white content) | .nds-dark |
.nds-stepper-circle.nds-featured-icon |
A solid fill, with a white icon or number |
| Icon color | Brand (default) (hint: The brand color, or the status around it) | — | .nds-stepper:not(.nds-oncolor) .nds-stepper-circle.nds-featured-icon |
The brand color, or the color of a status around it |
| Icon color | Green (hint: Success) | .nds-green |
.nds-stepper:not(.nds-oncolor) .nds-stepper-circle.nds-featured-icon |
The success color |
| Icon color | Blue (hint: Information) | .nds-blue |
.nds-stepper:not(.nds-oncolor) .nds-stepper-circle.nds-featured-icon |
The information color |
| Icon color | Yellow (hint: A warning) | .nds-yellow |
.nds-stepper:not(.nds-oncolor) .nds-stepper-circle.nds-featured-icon |
The warning color |
| Icon color | Red (hint: An error) | .nds-red |
.nds-stepper:not(.nds-oncolor) .nds-stepper-circle.nds-featured-icon |
The error color |
| Icon color | Neutral (hint: Gray, with no meaning) | .nds-neutral |
.nds-stepper:not(.nds-oncolor) .nds-stepper-circle.nds-featured-icon |
Gray, with no meaning of its own |
| Divider | Divider (hint: A label above each step, such as a date. Vertical only) | — | .nds-stepper.nds-vertical |
A divider at the start of each step, as its label: a date, a phase name, or a group of steps. Vertical only. See Divider Labels under Behavior |
| Divider | Divider (hint: A label above each step, such as a date. Vertical only) | — | .nds-stepper.nds-vertical-sm |
A divider at the start of each step, as its label: a date, a phase name, or a group of steps. Vertical only. See Divider Labels under Behavior |
| Divider | Divider (hint: A label above each step, such as a date. Vertical only) | — | .nds-stepper.nds-vertical-md |
A divider at the start of each step, as its label: a date, a phase name, or a group of steps. Vertical only. See Divider Labels under Behavior |
| Divider | Divider (hint: A label above each step, such as a date. Vertical only) | canon #stepper-label-1 |
.nds-stepper-step:nth-child(2) > .nds-stepper-content (start) |
The label of step 1 |
| Divider | Divider (hint: A label above each step, such as a date. Vertical only) | canon #stepper-label-2 |
.nds-stepper-step:nth-child(3) > .nds-stepper-content (start) |
The label of step 2 |
| Divider | Divider (hint: A label above each step, such as a date. Vertical only) | canon #stepper-label-3 |
.nds-stepper-step:nth-child(4) > .nds-stepper-content (start) |
The label of step 3 |
| Divider | Divider (hint: A label above each step, such as a date. Vertical only) | canon #stepper-label-4 |
.nds-stepper-step:nth-child(5) > .nds-stepper-content (start) |
The label of step 4 |
| Center | Center (hint: Each title centered under its circle. Horizontal only) | .nds-center |
.nds-stepper:not(.nds-vertical):not(.nds-radial) |
Centers each title under its circle. Horizontal only |
| Center | Center (hint: Each title centered under its circle. Horizontal only) | .nds-center |
.nds-stepper.nds-horizontal-sm |
Centers each title under its circle. Horizontal only |
| Center | Center (hint: Each title centered under its circle. Horizontal only) | .nds-center |
.nds-stepper.nds-horizontal-md |
Centers each title under its circle. Horizontal only |
| Separated | Separated (hint: No line between the steps) | .nds-separated |
.nds-stepper:not(.nds-radial):not(:has(> .nds-stepper-step.nds-card)) |
Removes the line between the steps. A vertical stepper gets spacing for steps with no line, and the text moves down to meet the circle. A card on each step does the same, so use this class for steps with no card |
| Action (any) | Button | canon #stepper-action |
.nds-stepper-step:nth-child(3) > .nds-stepper-content |
A button under the text of the current step. A row of buttons goes in the same nds-stepper-action |
| Action (any) | At end (hint: Beside the title, on the end side. Vertical only) | .nds-end |
.nds-stepper.nds-vertical .nds-stepper-action |
Moves the action to the end of the step’s first row, beside the text. A phone stacks it under the text. --stepper-action-width caps the column |
| Action (any) | At end (hint: Beside the title, on the end side. Vertical only) | .nds-end |
.nds-stepper.nds-vertical-sm .nds-stepper-action |
Moves the action to the end of the step’s first row, beside the text. A phone stacks it under the text. --stepper-action-width caps the column |
| Action (any) | At end (hint: Beside the title, on the end side. Vertical only) | .nds-end |
.nds-stepper.nds-vertical-md .nds-stepper-action |
Moves the action to the end of the step’s first row, beside the text. A phone stacks it under the text. --stepper-action-width caps the column |
| Card | None (default) | — | — | No card. The stepper has no surface of its own |
| Card | Stepper (hint: The whole stepper in one card) | .nds-card |
.nds-stepper |
The whole stepper in one Card. The usual use is a radial stepper, with the ring and the step on one surface. See Card under Behavior |
| Card | Step (hint: Each step in a card, with the line removed. Not radial or alternate) | .nds-card |
.nds-stepper:not(.nds-radial):not(.nds-alternate) .nds-stepper-step |
Each step in its own card, with the circle inside it. See Card under Behavior. Put the class on every step |
| Card | Content (hint: The text in a card beside the circle, with the line kept. Not radial) | .nds-card |
.nds-stepper:not(.nds-radial) .nds-stepper-content |
The text of each step in a card beside its circle. The line stays. Put the class on every step’s content |
| Stroke | Stroke (hint: A border in the card’s own color) | .nds-stroke |
.nds-stepper.nds-card |
A border around the stepper card |
| Stroke | Stroke (hint: A border in the card’s own color) | .nds-stroke |
.nds-stepper-step.nds-card |
On every step card: the card’s own border color in place of the step state color |
| Stroke | Stroke (hint: A border in the card’s own color) | .nds-stroke |
.nds-stepper-content.nds-card |
On every content card: the card’s own border color in place of the step state color |
| Shadow | Shadow | .nds-shadow |
.nds-card |
An elevation shadow under each card. It combines with the border |
| Neutral | Neutral (hint: A gray ring. Radial only) | .nds-neutral |
.nds-stepper.nds-radial |
A gray ring in place of the primary color. Radial only |
| Neutral | Neutral (hint: A gray ring. Radial only) | .nds-neutral |
.nds-stepper.nds-radial-sm |
A gray ring in place of the primary color. Radial only |
| Neutral | Neutral (hint: A gray ring. Radial only) | .nds-neutral |
.nds-stepper.nds-radial-md |
A gray ring in place of the primary color. Radial only |
| Loading | Loading (hint: Skeleton placeholders while the data loads) | .nds-loading |
.nds-stepper |
Every step shows as a skeleton while its data loads. Remove the class when the data is in |
Behavior
Radial
The radial layout shows the current step only, beside a ring. The script fills the ring and writes the step and the count in it, such as “2 / 4”. .nds-stepper-next under the description names the next step. Other layouts hide the ring and the next-step line, so one markup serves every layout.
Responsive Layout
A breakpoint class picks the layout on one screen size: nds-radial-sm on a phone, nds-vertical-md on a tablet. The layout class is the desktop layout, and the layout of a phone or tablet with no breakpoint class: nds-vertical, nds-radial, or none for horizontal. nds-vertical nds-radial-sm nds-radial-md is radial on phones and tablets, and vertical on a desktop. CSS picks the layout, so it changes as soon as the window crosses a breakpoint. The Phone and Tablet buttons on the preview show it at that width. A stepper that is radial on any size needs the ring markup.
Divider Labels
In a vertical stepper, a Divider at the start of a step’s content labels the step: a date, a phase name, or the name of a group of steps. Its line meets the circle and runs on as the separator between steps. A Timeline labels its events this way.
Card
nds-card on a part of the stepper gives that part the Card surface, with its options such as the shadow. On the stepper it makes one card around everything. On every step it puts the circle inside a card. On every step’s content it puts a card beside the circle and keeps the line. Put the class on every step, not on some.
A card on a step needs no other class. The line goes away, the spacing and the text change to fit, and the content fills the card. In a horizontal stepper, the cards share one height. It works with Dot, nds-reverse and divider labels. The border takes the color of the step state: the primary color for the current and the completed steps, the neutral color for the upcoming ones and on a static stepper. With nds-stroke, the card keeps its own border color in place of the state color.
A stepper with On color gives its cards the translucent white surface and the on-color text. Put nds-oncolor on the stepper only.
Separated
nds-separated hides the line between the steps in every layout. A vertical stepper then spaces its steps for a column with no line, and moves the text down to meet the circle’s center. A card on each step does the same with no class.
Icons
nds-icons on the stepper shows the icon in each circle in place of the number. Write one icon in every .nds-stepper-circle. The step states still color the circle, and a completed step shows a check mark in place of its icon. data-step-text shows nothing with icons.
Static
nds-static makes the stepper a plain list of steps in order, such as a how-it-works row. The script writes no step state, so data-current, the methods and the control buttons change nothing on screen. The line is neutral. Write nds-featured-icon nds-circle nds-outline on every .nds-stepper-circle: each circle is a Featured Icon, so its style and color classes change the look, such as nds-dark or nds-green. The stepper size still sets the circle size. Inside a status, such as an info Alert, the circles take that status color. A dot takes no featured icon classes. With nds-oncolor, the circles are light and a color class changes nothing. nds-dark then gives a white fill, like a completed step.
Step Action
A row of buttons in a step goes in nds-stepper-action, under the text. In a vertical stepper, nds-end on the row moves it to the end of the step’s first row, beside the title and the description. The column is as wide as its buttons, up to 40% of the step. A phone stacks the row under the text.
Step Controls
A button with data-stepper-control moves the stepper on every click, with no check. Use it only where nothing can refuse the move: a Back button, a walkthrough, or a Start Over button with goto. data-stepper-target names the stepper. Without it, the button moves the stepper it sits in, or else the first stepper on the page. The Back and Next buttons under the preview work this way.
Checked Moves
When something can refuse the move, such as validation or a request, call NDS.Stepper.next(id) from the code that gets the answer. Every form step is this case: the stepper never validates and never sends a request. A submit button with data-stepper-control inside a form is left to the form, so the stepper does not move and does not stop the submit. The example under API moves the stepper only when the step is valid.
Completion
next() on the last step completes the flow. It moves data-current one past the last step, marks every step completed, and writes completed in the stepper’s data-state. previous() then makes the last step current again. To show a finished flow at page load, write that same data-current. In the radial layout, the last step stays in view with a full ring.
Built-in Features
-
Auto-initialization
The script starts every
nds-stepperon the page. There is nothing to call. -
Automatic State Management
Write
data-currentand the script marks every step completed, current or upcoming. Write a new number later and the steps change with it. -
Automatic Numbers
CSS numbers the circles in order, and a completed step shows a check mark.
data-step-texton a circle shows other text in place of the number. -
Placeholders Before Start
Until the script starts, each step shows as a skeleton in its final layout. A radial stepper shows its first step, so it never shows empty.
-
Step Change Events
The stepper fires
nds:stepper:changeafter every move, with the current step, the step count and the percent done. -
Programmatic Control
A script moves a stepper with
NDS.Stepper.next(id),NDS.Stepper.prev(id)andNDS.Stepper.goTo(id, step).
Best Practices
- Give the stepper an
id. Control buttons and the JavaScript methods find the stepper by its id. - Keep a title to 2 to 4 words. Put the rest in the description.
- Keep a horizontal stepper to 3 to 5 steps, so every title fits its column. A radial stepper reads best with 3 to 6 steps.
- A horizontal stepper has no room on a phone. Add
nds-radial-smand the ring markup, so a phone shows the radial layout. - Move a form step with
NDS.Stepper.next(), notdata-stepper-control. Validation or a request can refuse the move. - Give every control button
type="button". Inside a form, a button with no type is a submit button, and the stepper leaves it to the form. - Write
.nds-stepper-nextin every radial step except the last. - Put
nds-cardon every step or on every step’s content. A stepper with some cards and some plain steps does not line up. - Put one main button in an action with
nds-end. A row of buttons wraps inside its narrow column. - To change the layout after load, change the class on the stepper. CSS alone sets the layout, so the change shows at once.
- Use
nds-staticfor a list that explains an order. A flow the user moves through keeps the step states. - Give a circle icon
aria-hidden="true". The step title names the step. - Name the current step in the page as well, such as in the form heading. A screen reader hears the current step, but not which steps are completed or upcoming.
API
Other Classes
| Class | Element | Effect |
|---|---|---|
nds-horizontal-sm, nds-vertical-sm, nds-radial-sm |
.nds-stepper |
The layout on a phone: narrower than 600px. See Responsive Layout under Behavior |
nds-horizontal-md, nds-vertical-md, nds-radial-md |
.nds-stepper |
The layout on a tablet: 600px to 959px |
nds-md |
.nds-stepper.nds-radial |
The 64px ring. It is the default, so it needs no class |
nds-stepper-action |
div in .nds-stepper-content |
A row of buttons in a step. Each button keeps its own width |
nds-row |
.nds-stepper-content |
The parts of the step side by side, from the start edge, such as a Date Tile beside the text |
nds-reverse |
.nds-stepper in a vertical layout |
The last step on top. Write the steps oldest first. For a Timeline |
Data Attributes
| Attribute | Element | Effect |
|---|---|---|
data-current |
.nds-stepper |
The current step, from 1. Write it at page load: without it, step 1 is current. The script watches it: write a new number and the steps change, and nds:stepper:change fires. Code that holds the step number, such as a framework view, can drive the stepper this way. A number one past the last step shows every step completed. A static stepper ignores it |
data-total |
.nds-stepper |
The number of steps. The script writes it when it starts. After you add or remove steps, write the new count in it, and the script reads the steps again |
data-state |
.nds-stepper |
The script writes completed when next() runs on the last step, or when data-current is past it. It removes it when the stepper moves back. Write loading yourself to show the skeleton: it works the same as nds-loading |
data-state |
.nds-stepper-step |
The script writes completed, current or upcoming on each step from data-current. It colors the circle and the border of a card on the step or its content. The script writes none on a static stepper. Do not write it yourself |
aria-current="step" |
.nds-stepper-step |
The script writes it on the current step, so screen readers hear it. No step has it when all are completed, or on a static stepper |
data-step-text |
.nds-stepper-circle |
Text in place of the step number, such as a letter. A completed step shows its check mark. A dot and nds-icons show no text |
data-stepper-control |
button |
next, previous or goto. The click moves the stepper. See Step Controls under Behavior |
data-stepper-target |
button with data-stepper-control |
The id of the stepper the button moves |
data-stepper-value |
button with data-stepper-control="goto" |
The step number to go to |
CSS Custom Properties
Set these on .nds-stepper. The size classes set --stepper-size too, so set it in the stepper’s style to win over them.
| Property | Default | Controls |
|---|---|---|
--stepper-size |
32px |
Circle diameter, or ring diameter in the radial layout |
--stepper-gap |
from the layout | Space between steps. Unset, it is --stepper-indicator-gap in a row (1.2 times with nds-lg, 1.5 times with nds-xl), 1.5 circles in a column, half a circle in a column of cards on the content, var(--spacing-xl) in a column with no line (a card on each step has none), and a spacing token that grows with the size in the radial layout |
--stepper-indicator-gap |
var(--spacing-md) |
The space between steps in a row, before the size classes scale it |
--stepper-text-padding |
var(--spacing-xl) |
Space between the circle and the step content |
--gap |
var(--spacing-xl) |
Space between the parts of a step’s content: a label divider, the text, a list, a row of buttons |
--stepper-content-width |
var(--paragraph-max-width) |
The widest a step’s content gets. Set none for a step that holds a table or a wide image. With a card on the step the default is none, so the content fills the card |
--divider-lift |
calc(var(--stepper-size) / 4) |
Moves a label divider down, so its line meets the middle of the circle. 0 by default with nds-dot, nds-separated, or a card on a step or on its content. Set 0 to leave the divider where it falls |
--stepper-card-lift |
calc(var(--stepper-size) / 4) |
How far a card on the content rises in a column, so its first line meets the circle. var(--stepper-size) with nds-dot. Set it when the content starts with something taller or shorter than a title |
--stepper-action-width |
40% |
The widest the action column gets with nds-end, as a share of the step. A row of buttons wraps inside it |
--stepper-title-FS, --stepper-title-LH |
set by the size class | Title font size and line height in the radial layout. The text does not grow with the ring, so set them for a large title beside a small ring. Set both |
--stepper-description-FS, --stepper-description-LH |
set by the size class | Font size and line height of the description and the next-step line in the radial layout |
Tokens
Set a token at :root, or on a wrapper to reach every stepper inside it. Give a token with a Dark mode value a dark override too: see Tokens.
Source: the stepper group in _sass/tokens/_components.scss.
| Token | Preview | Value |
|---|---|---|
--stepper-button-completed | var(--colors-primary-600)Dark mode var(--colors-primary-500) | |
--stepper-button-completed-hovered | var(--colors-primary-700)Dark mode var(--colors-primary-600) | |
--stepper-button-current | var(--colors-primary-600)Dark mode var(--colors-primary-500) | |
--stepper-button-current-hovered | var(--colors-primary-700)Dark mode var(--colors-primary-600) | |
--stepper-button-upcoming | var(--colors-neutral-300)Dark mode var(--colors-neutral-600) | |
--stepper-button-upcoming-hovered | var(--colors-neutral-400)Dark mode var(--colors-neutral-600) | |
--stepper-button-background | var(--background-default)Dark mode var(--colors-neutral-800) | |
--stepper-text-primary | var(--text-display)Dark mode var(--colors-neutral-100) | |
--stepper-text-secondary | var(--text-primary-paragraph)Dark mode var(--colors-neutral-300) | |
--stepper-text-tertiary | var(--text-secondary-paragraph)Dark mode var(--colors-neutral-400) | |
--stepper-line-completed | var(--colors-primary-600)Dark mode var(--colors-primary-500) | |
--stepper-line-current | var(--colors-neutral-300)Dark mode var(--colors-neutral-600) | |
--stepper-line-upcoming | var(--colors-neutral-300)Dark mode var(--colors-neutral-600) |
It also reads these shared tokens. A change to one also changes other components.
Source: the var() reads in _sass/components/_stepper.scss.
| Token | Preview | Value |
|---|---|---|
--background-surface-oncolorRead by background-color, --date-tile-bg, border-color, --progress-color | var(--colors-base-white) | |
--background-neutral-lightRead by --date-tile-bg | var(--colors-neutral-100)Dark mode var(--colors-alpha-white-10) | |
--background-primaryRead by background-color | var(--colors-primary-600) | |
--text-oncolor-primaryRead by --date-tile-color, color, --card-text-color | var(--colors-base-white) | |
--text-oncolor-secondaryRead by color | var(--colors-alpha-white-80) | |
--text-oncolor-tertiaryRead by color | var(--colors-alpha-white-70) | |
--progress-background-neutralRead by --progress-color | var(--colors-neutral-700)Dark mode var(--colors-neutral-200) |
JavaScript
The NDS.Stepper script loads after the page shows. Until it loads, each call loads it and returns a promise of the result, so await a call whose result you use.
A stepper in the page starts by itself. The instance is on the element as el.ndsStepper, and NDS.Stepper.getInstance(idOrEl) returns it. It is there once the component starts: code that runs at page load waits for NDS.init.ready.
| Method | Effect |
|---|---|
NDS.Stepper.init() |
Starts every .nds-stepper that has not started |
NDS.Stepper.create(el) |
Starts one stepper, such as one added after load, and returns its instance |
NDS.Stepper.destroy(idOrEl) |
The same as instance.destroy() |
NDS.Stepper.getInstance(idOrEl) |
Returns the instance of the stepper with that id, or on that element. null when there is none |
NDS.Stepper.next(idOrEl), NDS.Stepper.prev(idOrEl) |
Moves one step. On the last step, next() completes the flow |
NDS.Stepper.goTo(idOrEl, step) |
Moves to a step number. One past the last step completes the flow. Returns false for any other number outside the steps |
NDS.Stepper.control(idOrEl, action, value) |
What a control button calls. action is next, previous or goto, and value is the step for goto |
instance.next(), instance.prev(), instance.goTo(step) |
The same moves on one instance |
instance.current, instance.total, instance.progress |
The current step, the number of steps, and the percent done. current is one past the last step when the flow is completed |
instance.destroy() |
Removes the instance. The stepper keeps its look, and a later init() or create() starts it again |
| Event | Fired on | Detail |
|---|---|---|
nds:stepper:change |
.nds-stepper, and bubbles |
currentStep, totalSteps, progressPercentage. currentStep is one past the last step when the flow is completed, the same number data-current takes. Fires after every move, and after a script writes data-current or data-total. It does not fire when the stepper starts |
The full API is in the banner of _js/nds-stepper.js.