Zubra UI
Code for
GitHub

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

Compiled (any project)
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
One file, no dependencies (3.1 KB gzipped)
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
.zb source (to edit it with Zubra)
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
No build: a script tag, straight from this site
HTML
<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

index.html
<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>
Example.jsx
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>
  );
}
Example.vue
<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('-') } } }) -->
Example.svelte
<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>
example.component.ts
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

Properties (each is also an HTML attribute of the same name, unless marked)
PropertyTypeDefault
steps
property only
unknown[][]
currentnumber0
readonlybooleanfalse
Events
EventWhen
stepselectA 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.

Theme

Every component reads shadcn/ui's CSS variables, so any shadcn theme works. Pick a look or a colour, or paste a theme's CSS.

Look: colours, fonts, corners and motion

Accent colour