SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

stepper

Press-and-hold repeat for a NumberField group's increment/decrement buttons, calling the field's native stepUp()/stepDown() on an interval for as long as a button stays pressed.

tsx
import { stepper } from "@sdxc/ui/mixins";

Usage

Adds press-and-hold repeat to a NumberField group's Invoker-Command increment/decrement buttons. The trailing click after a hold-repeat gesture is absorbed so it doesn't add one extra step atop the repeat.

Signature

typescript
stepper(options?: StepperOptions): MixinDescriptor<HTMLElement>

Parameters

ParameterTypeDefaultRequiredDescription
optionsStepperOptions—NoHold-to-repeat timing overrides.

Examples

tsx
<div role="group" mix={[stepper()]}>
	<button type="button" command={NUMBER_FIELD_STEP_DOWN_COMMAND} commandfor="quantity" aria-label={decrementLabel}>
		<MinusIcon />
	</button>
	<input id="quantity" type="number" min={0} max={99} defaultValue={1} />
	<button type="button" command={NUMBER_FIELD_STEP_UP_COMMAND} commandfor="quantity" aria-label={incrementLabel}>
		<PlusIcon />
	</button>
</div>

The events, constants and types its module publishes, each imported from @sdxc/ui/mixins too.

Event

NumberFieldStepEvent

Dispatched on the number input immediately after stepper() applies a step, carrying the direction and freshly stepped value so a consumer can react without diffing input/change events against the prior value.

typescript
new NumberFieldStepEvent(direction: NumberFieldStepDirection, value: number)
PropertyTypeDefaultRequiredDescription
direction"increment" | "decrement"—YesWhich direction the value just moved.
valuereadonly number—YesThe input's valueAsNumber immediately after the step.
Constant

NUMBER_FIELD_STEP_UP_COMMAND

Custom Invoker Command an increment button declares (command="--step-up" commandfor pointing at the group's number input), read back by stepper() to call stepUp() on the matching input.

typescript
const NUMBER_FIELD_STEP_UP_COMMAND = "--step-up"
Constant

NUMBER_FIELD_STEP_DOWN_COMMAND

Custom Invoker Command a decrement button declares (command="--step-down" commandfor pointing at the group's number input), read back by stepper() to call stepDown() on the matching input.

typescript
const NUMBER_FIELD_STEP_DOWN_COMMAND = "--step-down"
Constant

NUMBER_FIELD_STEP_EVENT

Event type stepper() dispatches on the number input after every completed step, whether triggered by a single activation or by one tick of hold-to-repeat.

typescript
const NUMBER_FIELD_STEP_EVENT = "ui:number-field-step" as const
Interface

StepperOptions

Options accepted by stepper to tune its hold-to-repeat timing.

MemberTypeDefaultRequiredDescription
holdDelayMsnumber—NoMilliseconds a step button must stay pressed before hold-repeat begins. Defaults to DEFAULT_HOLD_DELAY_MS.
holdIntervalMsnumber—NoMilliseconds between repeated steps once hold-repeat has begun. Defaults to DEFAULT_HOLD_INTERVAL_MS.
Type

NumberFieldStepDirection

Direction a single step moves a NumberField's value: "increment" raises it, "decrement" lowers it.

typescript
type NumberFieldStepDirection = "increment" | "decrement"
@sdxc/ui

Can’t find it? Contact us