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
- Cart, completed3 items
- ShippingAddress and speed
- Payment
- Review
When to use it
- A checkout or an onboarding split in pages.
- A multi-part form that saves between parts.
States
- Account
- Team
- Done
- Account, completed
- Team, completed
- Done, completed
Minimal example
JxSteps(current: 1, [
JxStep(label: 'Cart'),
JxStep(label: 'Shipping'),
JxStep(label: 'Payment'),
])
Complete example
A full Jaspr component you can paste into a project.
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
classesto add or override utilities: they come last, soclasses: '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
mdbreakpoint.
Accessibility
-
An ordered list
<ol>with anaria-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.