This browser is not supported. The glass needs a Chromium browser or Electron. Why

Stepper

Increment and decrement buttons with the system's press and repeat timing. Flat, as on iOS: no glass.

import { Stepper } from "@adamexu/glass";

With a value

The label (children) sits at the leading edge and the control at the trailing one. At an end of in that side dims and stops; a step past an end lands on it. labelsHidden only speaks the label and puts the control at the leading edge on its stronger fill.

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

<Stepper value={guests} onChange={setGuests} in={[1, 8]}>
  Guests: {guests}
</Stepper>
<Stepper defaultValue={5} step={5} in={[0, 50]} labelsHidden aria-label="Quantity">
  Quantity
</Stepper>

Manual form

With onIncrement and onDecrement the stepper keeps no value of its own, and neither side ever dims.

Page 1
const [page, setPage] = useState(1);

<Stepper onIncrement={() => setPage(page + 1)} onDecrement={() => setPage(Math.max(1, page - 1))}>
  Page {page}
</Stepper>

In a List

In a List's row the scroll view gets the touch first: the press shows 190 ms after touch-down (a quick tap shows nothing but still steps), the first repeat comes at 666 ms, and a vertical drag before the press shows scrolls the list instead.

const [quantity, setQuantity] = useState(3);
const [tens, setTens] = useState(20);

<NavigationStack
  root={
    <NavigationPage title="Order">
      <List>
        <Section header="Stepper">
          <Stepper value={quantity} onChange={setQuantity} in={[0, 10]}>
            <Text>Quantity: {quantity}</Text>
          </Stepper>
          <Stepper value={tens} onChange={setTens} in={[0, 25]} step={10}>
            <Text>By tens: {tens}</Text>
          </Stepper>
          <Stepper defaultValue={3} disabled>
            <Text>Disabled</Text>
          </Stepper>
        </Section>
      </List>
    </NavigationPage>
  }
/>

Props

PropTypeDefaultDescription
valuenumber-Controlled value.
defaultValuenumber0Initial value when uncontrolled.
onChange(value: number) => void-Each step, including each repeat while held.
inreadonly [number, number][-Infinity, Infinity]The range. An end dims its side and stops there; a step past it lands on it.
stepnumber1The size of one step.
onIncrement() => void-The manual form: no value of its own, neither side ever dims.
onDecrement() => void-The manual form's other side.
disabledbooleanfalseStops responding. It looks the same, as on iOS.
labelsHiddenbooleanfalseThe label is only spoken; the control sits at the leading edge on its stronger fill.
childrenReactNode-The label, at the leading edge.
aria-labelstring-Names the role="group"; a string label names it otherwise.
className, stylestring, CSSProperties-On the outer box.

Behaviour

A press shows at once and acts when it lifts, on the side under the finger; a finger slid off the control only pauses it. Held, it repeats from touch-down: after 506 ms, five times at 501 ms, fourteen at 102 ms, then every 52 ms.

It is a role="group" of two buttons named Decrement and Increment. Each takes focus, and Enter or Space steps once. A side at its end is aria-disabled.

SwiftUI

SwiftUI@adamexu/glass
Stepper(title, value:, in:, step:)<Stepper value onChange in step>title</Stepper>
Stepper(title) { } onDecrement: { }<Stepper onIncrement onDecrement>title</Stepper>
.labelsHidden()labelsHidden
.disabled(true)disabled