Fragiola

API: components

Steps

A process in a fixed number of steps, an ordered list with aria-current="step", the step's content, Previous, Next and linear validation.

A process in a fixed number of steps: a checkout, an onboarding, a setup wizard. The APG has no stepper pattern and Base UI has no Steps, so the semantics are the APG-closest ones: an ordered list of the steps with the current one aria-current="step" (the value WAI-ARIA defines for the current step of a process), each step's trigger a native button in the tab order, the current step's content shown, and Previous and Next. In a linear process a step is reached only once every step before it is valid.

Checkout stepper
Gallery

Behaviour

  • Step: from 0, controlled or not; count is the completed state (the CompletedContent shows, Next is disabled). A step outside [0, count] is clamped.
  • Reaching a step: a step before the current one always; a later one always, unless linear, where it needs every step before it to be valid (isStepValid(index), read at each render, every step valid by default). Next needs the current step to be valid with linear.
  • Changes: a Trigger reports trigger-press, Previous previous-press, Next next-press; a Trigger of the current step reports nothing.
  • Semantics: a list, not a tablist: the server render cannot know whether triggers will render, and a list holds both a clickable stepper and a display-only one.
  • No text: name the List (aria-label); the triggers are named by their text (the Indicator is hidden from assistive technology).

Anatomy

partelementdata-primitives-partrole
Rootdivsteps-rootholds the step and the validation
Listolsteps-listthe steps
Itemlisteps-itemone step
Triggerbuttonsteps-triggermoves to its step
Indicatorspansteps-indicatorits number or check mark, hidden
Separatordivsteps-separatorthe line to the next step, hidden
Contentdivsteps-contenta step's content, hidden unless current
PrevTriggerbuttonsteps-prev-triggerthe step before
NextTriggerbuttonsteps-next-triggerthe step after
CompletedContentdivsteps-completed-contentshown once completed

Usage

import { Steps } from "@fragiola/primitives-react/steps";

<Steps.Root count={3} linear isStepValid={(index) => valid[index]}>
    <Steps.List aria-label="Checkout">
        {["Shipping", "Payment", "Review"].map((title, index) => (
            <Steps.Item key={title} index={index}>
                <Steps.Trigger>
                    <Steps.Indicator>{index + 1}</Steps.Indicator>
                    {title}
                </Steps.Trigger>
                <Steps.Separator />
            </Steps.Item>
        ))}
    </Steps.List>
    <Steps.Content index={0}>…</Steps.Content>
    <Steps.Content index={1}>…</Steps.Content>
    <Steps.Content index={2}>…</Steps.Content>
    <Steps.CompletedContent>Order placed</Steps.CompletedContent>
    <Steps.PrevTrigger>Back</Steps.PrevTrigger>
    <Steps.NextTrigger>Continue</Steps.NextTrigger>
</Steps.Root>;

Props

Every part also takes what the primitive contract gives: render (Vue: as and the render slot), a class and a style, a ref, and any attribute, which it forwards. Vue binds them as props (v-model:step, :is-step-valid), and Angular as inputs ([(step)], [isStepValid]).

Root

proptypedefaultdescription
stepnumberthe current step, from 0; count is the completed state (controlled)
defaultStepnumber0the step at first
onStepChange(step, details) => voidevery step change, with its reason; Vue @step-change (and update:step), Angular (stepChangeDetails) (and (stepChange), the step alone)
countnumberrequiredthe number of steps
linearbooleanfalsea step is reached only once every step before it is valid
isStepValid(index) => booleanevery step validwhether a step is valid, read at each render (Angular: in a computed, so it reads signals)
orientation"horizontal" | "vertical""horizontal"data-orientation on the parts

List

No props of its own; name it with aria-label.

Item

proptypedefaultdescription
indexnumberrequiredits step, from 0

Trigger

proptypedefaultdescription
onClick (react)MouseEventHandlera click, after the Trigger's own; not while disabled

Indicator

No props of its own.

Separator

No props of its own.

Content

proptypedefaultdescription
indexnumberrequiredits step, from 0

PrevTrigger

proptypedefaultdescription
onClick (react)MouseEventHandlera click, after the trigger's own; not while disabled

NextTrigger

proptypedefaultdescription
onClick (react)MouseEventHandlera click, after the trigger's own; not while disabled

CompletedContent

No props of its own.

State and part attributes

A part's state is its step's: current, completed (before the step, or the process completed) or incomplete (after it).

partattributes
Rootdata-orientation; data-completed once completed
Itemaria-current="step" on the current one; data-current, data-completed, data-incomplete; data-disabled while out of reach; data-orientation
Triggertype="button"; aria-current="step" on the current one; aria-controls its Content; disabled while out of reach; the Item's data-*
Indicator, Separatoraria-hidden="true"; the Item's data-current, data-completed, data-incomplete
Contenthidden unless current; data-current
PrevTrigger, NextTriggertype="button"; disabled and data-disabled where they cannot move
CompletedContenthidden unless completed

Keyboard

The browser's: Tab and Shift+Tab move through the enabled triggers, Enter or Space presses one.

Exports

entryexports
@fragiola/primitives-react/stepsSteps, ChangeDetails, ChangeReason, RenderProp, StepsCompletedContentProps, StepsContentProps, StepsIndicatorProps, StepsItemProps, StepsItemState, StepsListProps, StepsNextTriggerProps, StepsPrevTriggerProps, StepsRootProps, StepsSeparatorProps, StepsState, StepsStepTriggerProps, StepsStepTriggerState, StepsTriggerProps
@fragiola/primitives-vue/stepsSteps, ChangeDetails, ChangeReason, RenderSlotProps, StepsContentProps, StepsItemProps, StepsItemState, StepsRootEmits, StepsRootProps, StepsState, StepsStepTriggerState
@fragiola/primitives-angular/stepsChangeDetails, ChangeReason, StepsCompletedContent, StepsContent, StepsIndicator, StepsItem, StepsItemState, StepsList, StepsNextTrigger, StepsPrevTrigger, StepsRoot, StepsSeparator, StepsState, StepsStepTriggerState, StepsTrigger, ValueChangeEvent