Spinbutton

A spinbutton is a numeric input that lets users type a value or adjust it with increment and decrement controls.

Spinbuttons are suited for discrete numeric values such as quantities or counts. When users need to select a numeric value within a defined range, a slider may be more appropriate.

Accessibility Features

Feature types: Required Recommended
  • An input field must have its own visible <label>, associated via matching for and id attributes or nesting. Multiple interactive controls must not be nested inside a single <label>.
  • type="number" provides the spinbutton role and behavior.
  • aria-label provides the increment and decrement buttons (+ and −) with descriptive accessible names, and a visually hidden <output> region announces the updated input value to screen readers when the buttons are pressed. Alternatively, the buttons can be hidden from screen readers and the keyboard with aria-hidden="true" and tabindex="-1", since the input itself provides an alternative way to change the value.

Example

Code Snippet