Navigation

Steps

Where the user is in a flow of several steps: complete steps get a check mark, the current one is announced with aria-current="step".

JxSteps import 'package:jx_cli/ui.dart' New in 0.0.3

Preview

  1. Cart, completed3 items
  2. ShippingAddress and speed
  3. Payment
  4. Review

When to use it

  • A checkout or an onboarding split in pages.
  • A multi-part form that saves between parts.

States

  1. Account
  2. Team
  3. Done
First step
  1. Account, completed
  2. Team, completed
  3. Done, completed
Every step complete

Minimal example

Dart
JxSteps(current: 1, [
  JxStep(label: 'Cart'),
  JxStep(label: 'Shipping'),
  JxStep(label: 'Payment'),
])

Complete example

A full Jaspr component you can paste into a project.

Dart
import 'package:jaspr/jaspr.dart';
import 'package:jx_cli/ui.dart';

/// Steps above the page of a checkout, named for screen readers.
class CheckoutHeader extends StatelessComponent {
  const CheckoutHeader({required this.step, super.key});

  final int step;

  @override
  Component build(BuildContext context) {
    return JxSteps(
      current: step,
      label: 'Checkout progress',
      completeLabel: 'done',
      classes: 'mb:8',
      const [
        JxStep(label: 'Cart', description: 'Review your items'),
        JxStep(label: 'Shipping', description: 'Address and speed'),
        JxStep(label: 'Payment', description: 'Card or transfer'),
      ],
    );
  }
}

Properties

Property Type Default Description
steps List<JxStep> required The steps, in order.
current int required Index of the step in progress; steps.length marks them all complete.
label String 'Progress' Accessible name of the list.
completeLabel String 'completed' Read after the label of each complete step.
classes String? null Extra JX classes, appended after the component classes.

Related types

Name Role
JxStep(label:, description:) One step, with an optional second line.

Customizing

  • Pass classes to add or override utilities: they come last, so classes: 'w:full' wins over the default width.
  • Complete and current steps use blue-700, upcoming ones the muted border.

Responsive

  • A vertical list on phones, a row with connectors from the md breakpoint.

Accessibility

  • An ordered list <ol> with an aria-label: screen readers announce the number of steps.
  • The current step has aria-current="step"; complete steps end with a hidden ", completed".
  • Numbers, check marks and connectors are decorative (aria-hidden).

Limitations

  • Display only: steps are not links. Put your own navigation buttons under it.