Kinetic Number Stepper

A number field with minus and plus buttons that repeat while held. Typed values are clamped to min and max when you leave the field.

  • <kt-kinetic-number>
  • Inputs
  • No framework

Kinetic Number Stepper

The code

Copy the Kinetic Number Stepper

Fastest: press Copy on the card above for one complete file. To build it into your own project, use the files below: the markup, the styles, this component’s script and the shared effects script (effects.js) that every component uses.

<kt-kinetic-number label="Seats" value="5" min="1" max="50" step="1"></kt-kinetic-number>

<kt-kinetic-number label="Opacity" value="0.8" min="0" max="1" step="0.1"></kt-kinetic-number>

<kt-kinetic-number label="Timeout" value="30" min="5" max="300" step="5" unit="sec"></kt-kinetic-number>

Attributes

NameWhat it doesDefault
valueCurrent number, always inside min and max.min or 0
minLowest allowed value. Unset means no lower limit.—
maxHighest allowed value. Unset means no upper limit.—
stepAmount each press adds or removes. Decimals are rounded cleanly.1
labelText above the field.Quantity
unitShort unit shown inside the field, such as "sec".—
disabledPresent when the field cannot be used.—
readonlyPresent when the value can be read but not changed.—
sfxSound-effect text on the first press.ポン!

Keyboard and screen readers

  • The field has role="spinbutton" with aria-valuenow, aria-valuemin, aria-valuemax and aria-valuetext.
  • ArrowUp and ArrowDown change the value by step; PageUp and PageDown by ten steps; Home and End jump to min and max.
  • Enter or leaving the field commits a typed value, clamped to the range; Escape discards it.
  • The minus and plus buttons are named and disable at the limits; they stay out of the Tab order because the field itself handles the keys.
  • Holding a button repeats after a short delay and speeds up; fires change with { value }.

Styling variables

Every look is a CSS variable: --kt-accent, --kt-accent-ink, --kt-radius-btn, --kt-surface-radius, --kt-surface-bg, --kt-border-w, --kt-comp-shadow and --font-sans. The copied file sets them all from your choices.

FAQ

Kinetic Number Stepper: questions answered

How do I use the Kinetic Number Stepper?

Press Copy on the card to get a complete HTML file, or copy the HTML, CSS and JavaScript tabs into your own page. In your markup the element is written as <kt-kinetic-number>.

Which attributes does <kt-kinetic-number> accept?

value, min, max, step, label, unit, disabled, readonly, sfx. Each one is described in the attributes table on this page.

Is the Kinetic Number Stepper accessible?

The field has role="spinbutton" with aria-valuenow, aria-valuemin, aria-valuemax and aria-valuetext. ArrowUp and ArrowDown change the value by step; PageUp and PageDown by ten steps; Home and End jump to min and max. Enter or leaving the field commits a typed value, clamped to the range; Escape discards it. The minus and plus buttons are named and disable at the limits; they stay out of the Tab order because the field itself handles the keys. Holding a button repeats after a short delay and speeds up; fires change with { value }.

Can I change the Kinetic Number Stepper colors, corners and font?

Yes. Use the options on this page: accent color, border radius, background, border, shadow and Google font. The copied code already contains your choices, and every one of them is a CSS variable you can edit later.