Stepper

Increments or decrements a bounded number.

  • Native host
  • New in 0.1
import { Stepper, stepperPrimitive } from "nitro-ui-sdk/stepper";
HeroUI Native
NumberStepper (Pro)
Expo UI
Stepper
  • Stepper example screen, light appearance
    Light
  • Stepper example screen, dark appearance
    Dark
On this page

Increments or decrements a bounded numeric value in discrete steps, backed by UIStepper on iOS and a composed minus/plus button pair on Android. Use Stepper for exact counts, quantities, or small numeric adjustments; use Slider for wide continuous ranges.

Anatomy

<Stepper.Root label="Guests" min={1} max={10} step={1} defaultValue={2}>
  <Stepper.Label />
  <Stepper.Hint />
  <Stepper.Value />
  <Stepper.Control />
</Stepper.Root>
Part Description
Stepper.Root Manages bounded value state, wrapping behavior, controller attachment, and agent registration.
Stepper.Label Primary row label (hidden from duplicate screen-reader focus).
Stepper.Hint Optional helper text and accessibility hint.
Stepper.Value Formatted live value readout (formatValue(value)).
Stepper.Control Native UIStepper host on iOS (48 pt+ tap target) or composed minus/plus button pair on Android.

Usage

import { Stepper } from "nitro-ui-sdk/stepper";

<Stepper.Root label="Copies" min={1} max={20} defaultValue={1} />;

Variants and sizes

variant selects "default" (transparent row) or "outlined" (card-like surface with border). size supports "sm", "md" (default), and "lg", scaling row height and value typography while keeping at least 44 pt touch targets.

<Stepper.Root label="Retries" variant="outlined" size="sm" min={0} max={5} defaultValue={2} />
<Stepper.Root label="Seats" variant="outlined" size="lg" min={1} max={12} defaultValue={4} />

States

  • Wrapping: pass wraps so incrementing at max wraps to min and decrementing at min wraps to max.
  • Disabled: pass disabled to lock the control and dim captions with tokens.opacity.disabled.
<Stepper.Root label="Hour" min={1} max={12} wraps defaultValue={12} />
<Stepper.Root label="Locked limit" min={0} max={10} defaultValue={5} disabled />

Controlled

Provide value and onValueChange to control the numeric value. Calling details.preventDefault() declines the update; leaving value unchanged reconciles the native UIStepper back to the committed value.

import { useState } from "react";
import { Stepper } from "nitro-ui-sdk/stepper";

const [guests, setGuests] = useState(2);

<Stepper.Root
  label="Guests"
  min={1}
  max={8}
  value={guests}
  onValueChange={setGuests}
  formatValue={(n) => `${n} guests`}
/>;

Props

Stepper.Root

Prop Type Default Description
label string — Required visible and accessible name.
hint string undefined Optional helper text and accessibility hint.
min number 0 Lower bound of the range.
max number min + 100 Upper bound of the range.
step number 1 Positive increment per press.
wraps boolean false Wraps between max and min when stepping past bounds.
value number undefined Controlled numeric value (clamped and snapped to step).
defaultValue number min Initial uncontrolled value.
onValueChange (value: number, details: ActionDetails) => void undefined Called before the value changes.
formatValue (value: number) => string String Formats Stepper.Value and the spoken accessibility value.
decrementLabel string `Decrease ${label}` Accessible name for the minus button on Android.
incrementLabel string `Increase ${label}` Accessible name for the plus button on Android.
variant "default" | "outlined" "default" Row container appearance.
size "sm" | "md" | "lg" "md" Row height and value typography scale.
disabled boolean false Disables all interactions.
styles PartStyles<StepperPart, StepperVariant, StepperSize, StepperState> undefined Per-part style overrides.
api Controller<StepperActions> undefined Imperative controller created with stepperPrimitive.createApi().
agentId string undefined Stable agent identity when rendered in recyclable rows.
layout SharedViewProps["layout"] undefined Additional layout props merged onto the root container.
children ReactNode Default row anatomy Custom part composition.

Stepper.Label, Stepper.Hint, Stepper.Value, Stepper.Control

Prop Type Default Description
part StepperPart Matching part name Overrides the style slot resolved from styles.
children string From root props Optional text override on Label, Hint, or Value.

Controller API

import { Stepper, stepperPrimitive } from "nitro-ui-sdk/stepper";

const api = stepperPrimitive.createApi();
<Stepper.Root label="Quantity" min={0} max={10} api={api} />;
api.current?.increment();
Action Signature Result
setValue (value: number, source?: ActionSource) => ChangeStatus Clamps and snaps a finite number ("refused" for NaN/Infinity).
increment (source?: ActionSource) => ChangeStatus Increases by step (wrapping to min when wraps is true).
decrement (source?: ActionSource) => ChangeStatus Decreases by step (wrapping to max when wraps is true).

Styles

Style resolvers receive { tokens, variant, size, state } where state is { min: number; max: number; step: number; disabled: boolean; wraps: boolean; value: number; canIncrement: boolean; canDecrement: boolean }.

<Stepper.Root
  label="Temperature"
  defaultValue={21}
  styles={{
    value: ({ tokens }) => ({ text: { color: tokens.colors.accent } }),
  }}
/>

Accessibility

On iOS, StepperHostView exposes a single .adjustable accessibility element carrying accessibilityLabel, formatted accessibilityValue, accessibilityHint, and accessibilityIncrement/accessibilityDecrement actions, while forwarding touch direction from UIStepper through the shared SDK stepping model. On Android, the composed minus and plus buttons carry explicit localized labels (decrementLabel/incrementLabel) and disabled states at bounds. Touch presses fire selectionChanged() haptics. VoiceOver, TalkBack, and keyboard activation report details.source === "user" without haptics.

Agent API

Action Arguments Notes
setValue number (finite) Sets a bounded value and settles controlled updates.
increment none Increments by one step (respecting wraps) and settles controlled updates.
decrement none Decrements by one step (respecting wraps) and settles controlled updates.

Platform notes

iOS Android
Implementation Native UIStepper wrapped in an adjustable 48 pt+ tap host (HybridNativeStepper.swift). Composed minus/plus Semantics buttons sharing the same model, plus compile-only HybridNativeStepper.kt spec stub.
Verification Unit, type, iOS harness, and simulator screenshot verified. Composed TS tested via shared model; Android native build not run locally (no Android NDK on this machine).