React Native / Navigation
Stepper
Where you are in a multi-step flow. The position is read as one phrase ("Step 2 of 4: Games") and announced politely when it changes.
import { Stepper } from "@stylhero/native";
Example
import { useState } from "react";
import { Button, Stack, Stepper } from "@stylhero/native";
function StepperExample() {
const [step, setStep] = useState(1);
return (
<Stack gap={4}>
<Stepper steps={["Budget", "Games", "Resolution", "Review"]} current={step} onStepPress={setStep} />
<Button onPress={() => setStep((s) => Math.min(s + 1, 3))}>Next</Button>
</Stack>
);
}
Props
| Prop | Type | Default | Description |
|---|---|---|---|
current required |
number |
- | Index of the current step, from 0. |
steps required |
string[] |
- | Step names in order, e.g. ["Budget", "Games", "Look", "Review"]. |
formatPosition |
(step: number, total: number) => string |
defaultPosition |
Builds the spoken and visible "Step 2 of 4". |
onStepPress |
(index: number) => void |
- | Lets people go back: completed steps become buttons that call this with their index. |
style |
StyleProp<ViewStyle> |
- | |
testID |
string |
- | |
variant |
"bar" | "dots" |
"bar" |
"bar" (default): "Step 2 of 4" with the current step's name over a segmented bar; fits any number of steps and any text size. "dots": numbered circles with names under them, for up to four short names. Falls back to "bar" when the user's text size is large. |
Screen reader gestures
| Gesture (VoiceOver / TalkBack) | Does |
|---|---|
| Double-tap an earlier step | Goes back to it, with onStepPress |
Accessibility
- Read as one phrase, "Step 2 of 4: Games", and announced when the step changes.
variant="dots"falls back to the bar when the text size is above 1.3×, so the step name still fits.
Generated from src/components/Stepper.tsx. Something wrong or missing? Open an issue.