step-indicator
Where a multi-step flow is: steps done (which can be revisited), the current one, and those ahead. readonly shows where something is without offering to go back (an order's status): plain list items, not buttons. current past the last step shows every step done.
Try it: events appear here (stepselect).
Source: step-indicator.zb, and its registry item.
Install
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/step-indicator.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/step-indicator.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/step-indicator.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/step-indicator.json
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/step-indicator.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/step-indicator.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/step-indicator.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/step-indicator.json
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/step-indicator.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/step-indicator.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/step-indicator.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/step-indicator.json
<link rel="stylesheet" href="https://zubra-js.github.io/zubra-ui/themes/default.css">
<script type="module" src="https://zubra-js.github.io/zubra-ui/cdn/step-indicator.js"></script>The compiled install writes src/components/zubra/step-indicator.js and the theme, and adds @zubra/runtime to your dependencies. The one-file install writes the same path as a plain custom element that needs nothing installed (or download it and load it with a <script type="module">); it's smaller on a page with one to three components, the shared runtime with more.
Usage
<step-indicator></step-indicator>
<script type="module">
import './components/zubra/step-indicator.js';
const element = document.querySelector('step-indicator');
element.steps = ['Cart', 'Shipping', 'Payment', 'Review'];
element.current = 2;
element.addEventListener('stepselect', (event) => console.log('stepselect', event.detail));
</script>import './components/zubra/step-indicator.js';
const steps = ['Cart', 'Shipping', 'Payment', 'Review'];
const current = 2;
export function StepIndicatorExample() {
return (
<step-indicator
steps={steps}
current={current}
onstepselect={(event) => console.log('stepselect', event.detail)}
></step-indicator>
);
}<script setup>
import './components/zubra/step-indicator.js';
const steps = ['Cart', 'Shipping', 'Payment', 'Review'];
const current = 2;
const onStepselect = (event) => console.log('stepselect', event.detail);
</script>
<template>
<step-indicator
:steps.prop="steps"
:current.prop="current"
@stepselect="onStepselect"
></step-indicator>
</template>
<!-- vite.config.js: vue({ template: { compilerOptions: { isCustomElement: (tag) => tag.includes('-') } } }) --><script>
import './components/zubra/step-indicator.js';
const steps = ['Cart', 'Shipping', 'Payment', 'Review'];
const current = 2;
</script>
<step-indicator
{steps}
{current}
onstepselect={(event) => console.log('stepselect', event.detail)}
></step-indicator>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import './components/zubra/step-indicator.js';
@Component({
selector: 'app-step-indicator-example',
schemas: [CUSTOM_ELEMENTS_SCHEMA],
template: `
<step-indicator
[steps]="steps"
[current]="current"
(stepselect)="onStepselect($event)"
></step-indicator>
`,
})
export class StepIndicatorExample {
steps = ['Cart', 'Shipping', 'Payment', 'Review'];
current = 2;
onStepselect(event: Event) {
console.log('stepselect', (event as CustomEvent).detail);
}
}API
| Property | Type | Default |
|---|---|---|
stepsproperty only | unknown[] | [] |
current | number | 0 |
readonly | boolean | false |
| Event | When |
|---|---|
stepselect | A finished step was chosen; detail is its index. |
Size
1.2 KB gzipped for the component, plus the runtime, which every Zubra component on a page shares (up to 22.1 KB, all of it). On its own, with the parts of the runtime it uses, it's 17.4 KB.