ProgressTracker
A component that displays the current step in a multi-step process or workflow.
- (1)Step 1
- (2)Step 2
- (3)Step 3
Usage
Use standalone.
<ProgressTracker {...props} />Anatomy
The class attribute values represent part names, and conditional indicates elements that are rendered conditionally. Other attributes represent their corresponding props.
<ol class="whole" {...rest}>
{#each labels as label}
<li class="middle">
<div class="main">
<div class="aux" conditional>{aux}</div>
<div class="label">{label} or {children}</div>
</div>
<div class="extra" aria-hidden="true" conditional>{extra}</div>
</li>
{/each}
</ol>Props
| Name | Type | Default | Description |
|---|---|---|---|
current* | number | 0 | Index of the step currently progressing |
labels* | string[] | - | Step labels |
children | Snippet | - | Step content; receives index, label, and variant |
aux | Snippet | - | Auxiliary content; receives index, label, and variant |
extra | `boolean | Snippet` | true |
statusLabels | Record | - | Maps a variant to a screen-reader-only suffix appended to each step |
styling | SVSClass | - | Styling override |
variant | SVSVariant | NEUTRAL | Variant |
eachVariant | SvelteMap | - | Per-step variant |
* required. Other HTMLOlAttributes are passed to <ol> via rest props; class is merged onto the root.
Styling
To learn more, see Styling.
Variant Management
Current step and whole part are applied neutral. Steps less than current step will be active, greater than current will be inactive. If the variant prop is specified, the specified value is applied instead of neutral.
Default Class Name
svs-progress-tracker
Accessibility
ARIA Roles and Attributes
The component applies these automatically:
- Steps (
middle<li>):aria-current="step"on the current step, andaria-labelon non-current steps when a status suffix is available. - Connector (
extra<div>, when rendered):aria-hidden="true".
Pass statusLabels when custom variants need a screen-reader suffix; otherwise the default active state suffix is used.
Exports
Types
interface ProgressTrackerProps extends Omit<HTMLOlAttributes, "children"> {
current: number; // (0)
labels: string[];
children?: Snippet<[number, string, string]>; // Snippet<[index,label,variant]>
aux?: Snippet<[number, string, string]>; // Snippet<[index,label,variant]>
extra?: boolean | Snippet<[number, string, string]>; // (true) Snippet<[index,label,variant]>
statusLabels?: Partial<Record<string, string>>; // variant -> screen-reader suffix
styling?: SVSClass;
variant?: SVSVariant; // (VARIANT.NEUTRAL)
eachVariant?: SvelteMap<number, string> | Map<number, string>;
// other HTMLOlAttributes are passed to <ol> via ...rest; `class` is merged onto the root
}
type ProgressTrackerReqdProps = "current" | "labels";
type ProgressTrackerBindProps = never;Others
No additional exports are available.
Examples
The example code uses Tailwind CSS along with SVSClass.
Basic
- (1)Step 1
- (2)Step 2
- (3)Step 3
With Interactive Variant
- Step 1Additional text 1
- Step 2Additional text 2
- Step 3Additional text 3
- Step 4Additional text 4