Skip to content

Number Stepper

Enhance a native number input with increment controls. Custom element

Number Stepper
Copy this markup
<ui-number-stepper aria-labelledby="quantity-label">
<label id="quantity-label" for="quantity">Quantity</label>
<button type="button" data-ui-part="decrement" aria-label="Decrease Quantity"></button>
<input id="quantity" type="number" value="2" min="1" max="10">
<button type="button" data-ui-part="increment" aria-label="Increase Quantity">+</button>
</ui-number-stepper>

Install

Styles and registration
import '@timelessui/components/css/tokens.css'
import '@timelessui/components/css/number-stepper.css'
import '@timelessui/components/define/ui-number-stepper'

Anatomy

Parts are authored in your own markup and identified by the selector below, so your CSS can target the same anatomy without loading Timeless styles. Required parts must be present for the component to work. Private data-ui-internal-* hooks are written by the runtime and must never be authored.

PartRequiredSelectorPurpose
inputYesinput[type='number']The native number input. min, max, and step come from it, and native validation keeps working.
decrementYes[data-ui-part~='decrement']Button that steps down. Give it an accessible name.
incrementYes[data-ui-part~='increment']Button that steps up. Give it an accessible name.

Element API

Attributes above are the authoring surface. These are the DOM properties and events the registered element adds once it upgrades.

<ui-number-stepper>

This element adds no public properties. Configure it with the attributes above.

EventDetailDescription
inputEventNative input event dispatched on the inner number input after each step.
changeEventNative change event dispatched on the inner number input.

Styling

Root identity: ui-number-stepper. Required stylesheets: tokens.css, number-stepper.css.

This component adds no custom properties of its own. Restyle it through the design tokens or your own CSS.

Design tokens this component reads (11)

These are global Atmosphere tokens. Change them once at the theme level rather than per component.

--ui-bg-control-hover · --ui-bg-control-muted · --ui-disabled-opacity · --ui-fg · --ui-fg-muted · --ui-focus · --ui-font-mono · --ui-line · --ui-radius-md · --ui-space-2 · --ui-space-3

Accessibility

Keep the native elements, roles, and relationships shown in the example. Timeless adds only the state and keyboard coordination the platform does not already provide, and it never supplies your accessible names — those depend on your content.

Before JavaScript runs

The markup above is complete and usable on its own: native controls submit, labels associate, and authored ARIA is already correct. Registration adds state synchronisation, focus management, and keyboard coordination on top of it.

More examples

Open Number Stepper in StoryLite for variants, controls, and manual testing.