Skip to content
English
Ratchet stepper comes with Pro. Its preview shows once you unlock it.

How it works

A ratchet you can read and drive. The figure is a flat ratchet wheel in --ds-surface-2 with its pawl in ink: one tooth per stage, or the whole multiple that brings it nearest 16 to 20 teeth, each tooth a steep face, a flat top, a back slope and a flat root, all corners rounded, and a tick on a quiet face disc at the end of every stage. The wheel turns by value / max of a full turn; the teeth that have passed the pawl fill with the accent, so the reached share is a band that grows clockwise from the pawl. Beside it sit the label, the value as a display number, an optional caption and a status line; below it, the notched track with its handle and stop labels, then Reset and the next button. Every way of moving forward clicks the same way: turning the wheel clockwise by half a stage, dragging or pressing ahead on the track, the arrow keys or the next button. Moving back is refused, not ignored: the pawl turns warning-coloured and the wheel kicks back against it, the handle's arrow becomes a lock with a warning ring, and the status line says why; a pointer pulling back makes the wheel and handle lean against the pawl. Reset is the only way back to 0: it lifts the pawl and spins the wheel home.

Use it for

  • A staged rollout or exposure level that should only rise step by step, with one deliberate way back.
  • A count that must not be lowered by a slip: stamps on a loyalty card, glasses of water logged today, check-ins at a door.
  • Tiered progress that only moves forward until someone resets it on purpose.

Look elsewhere when

  • A value people adjust both ways: use a range slider or a number input.
  • Long continuous ranges with fine steps, where the notches and teeth would be too fine to read.

Usage

import { useState } from 'react'
import { WardrobeRatchet } from './WardrobeRatchet.jsx'

export function RolloutCard() {
  const [stage, setStage] = useState(0)
  const stops = ['0%', '1%', '5%', '25%', '50%', '100%']
  return (
    <WardrobeRatchet
      label="Rollout"
      stops={stops}
      value={stage}
      onChange={setStage}
      caption={`${Math.round(482 * parseFloat(stops[stage]))} users`}
      labels={{ reset: 'Roll back', advance: (next, stop) => (stop ? `Next: ${stop}` : 'Next stage') }}
    />
  )
}

Props

PropTypeDefaultWhat it does
value / defaultValue / onChangenumber / number / (value, { reason, previous }) => void- / 0 / -The notch, from 0 to max, controlled or uncontrolled. onChange fires only for a step forward (reason step or drag) or for Reset (reason reset); a host may also set a lower value itself.
onBlocked(attempted, held) => void—Called when a move back is refused (arrow key, Home, a press behind the handle, a drag backwards on the track or turning the wheel back), with the notch asked for and the one kept.
max / stopsnumber / Array<string | number>6 / -The number of steps. stops names every notch from 0 (its length minus one sets max); without it the notches are numbered. Up to ten notches are all labelled, more every few; labels that would touch give way, keeping both ends and the current one.
labelstring'Progress'The visible name beside the wheel and the accessible name of the handle.
captionReactNode—An optional short line under the display number, such as what the value means right now ("2,410 users"). Keep it to one line at 320px.
formatValue(value, stopLabel) => string—Text of the display number and the start of aria-valuetext. By default the stop's name or the number.
labelsobject—Replaces advance (a string or (next, stopLabel) => string, called with no arguments at the end), reset, start, position ((value, max) => string), done, blocked, resetDone and help (the handle's description for screen readers).
disabledbooleanfalseFades the stepper and ignores input.
...restHTMLAttributes—Other attributes go to the root <div>.

Accessibility

  • The handle is role="slider" with aria-valuemin, aria-valuemax, aria-valuenow and an aria-valuetext of the value and the stage; it is named by label and described by help.
  • Right, Up and PageUp step forward, End goes to the last notch; Left, Down, PageDown and Home are refused and announced. Tab reaches the handle, then Reset and the next button; Enter or Space presses them.
  • The status line is role="status" (polite), so a refusal, a reset or a step made with the buttons is read out.
  • Unavailable buttons use aria-disabled and stay focusable, so focus is not lost when the last step is reached.
  • A refusal shows a lock icon and words as well as the warning colour of the pawl and handle.
  • Touch: touch-action is none on the wheel and the track, the handle's hit area is 44px, and the buttons' tap area grows to 44px on coarse pointers. Turning the wheel needs a press on the wheel itself, not the empty corners of the figure. A cancelled pointer ends the drag cleanly.
  • The wheel is decoration for assistive tech (aria-hidden); the handle on the track carries the value. Reduced motion places the wheel, handle and fill at once with no click, kick, nudge or lean; the accent teeth, the warning pawl, the lock, the ring and the status line still show the state.

Motion

A step: the wheel turns one stage and the handle and fill move over --ds-duration-fast on --ds-ease-spring, while the pawl lifts and drops over --ds-duration-base, a click; the newly passed teeth take the accent one after another as they pass the pawl. Reset, or a host lowering the value: the pawl lifts and the wheel spins home over --ds-duration-slow on --ds-ease-in-out, the accent emptying tooth by tooth. A refusal from the keyboard kicks the wheel 2.5deg back against the pawl and nudges the handle 6px over --ds-duration-slow; while a pointer pulls back, the wheel leans up to 2.5deg against the pawl (5deg when pushed forward) and the handle up to 6px, springing back over --ds-duration-base when released. Colours and icons cross-fade over --ds-duration-fast.

Add it to your project

Pro members copy a prompt and their coding agent installs the source, the same way as the free components.

WardrobeRatchet.jsxwardrobe-ratchet.csstokens.cssREADME.md

Both files install together. The stylesheet reads the design tokens in tokens.css and carries fallbacks, so it also works alone.

Form inputs
Availability grid comes with Pro. Its preview shows once you unlock it.
Boolean operations comes with Pro. Its preview shows once you unlock it.
Cascader comes with Pro. Its preview shows once you unlock it.