Skip to content

role spinbutton

Number field draft v0.1.0

Lets people enter a number, by typing it or stepping it up and down.

A number field collects a numeric value within optional bounds and steps: a quantity, a percentage, a year. It is a Text field for numbers, with the platform's own stepping control (arrow keys, a spin control) and validation of the bounds. A value whose exact figure matters less than its position in a range is a Slider; a phone number or a postal code is text, not a number: use a Text field.

Guidelines

From apps/docs/content/components/number-field.md

Overview

A number field collects a numeric value within optional bounds and steps: a quantity, a number of seats, a year. It looks like the Text field and adds the platform’s stepping: arrow keys and a spin control, which keeps its native look. The browser validates the bounds; the field shows the error message the form gives it.

This page applies to every platform. Where a platform differs, the difference sits under a sub-heading named after it (Web, iOS, Android, Desktop); everything else holds everywhere.

When to use

  • A quantity people count or step: items in a cart, seats, rows per page, a year.
  • A value with meaningful bounds and increments.

When not to use

  • A number that is really text: a phone number, a postal code, a card number. Use a Text field; a spin control makes no sense there and assistive technology would announce a spinbutton.
  • A value whose position in a range matters more than its figure. Use a Slider, alone or next to the number field.

Sizes, states and content

Sizes (small, medium, large), states (default, hover, focus visible, invalid, read-only, disabled) and the label, description and error message follow the Text field. The label names the quantity and its unit when it has one (Weight (kg)); the description gives the bounds (Between 1 and 99); the error message says how to fix the value.

Accessibility

The Specification tab lists the full accessibility contract, grouped into what holds on every platform and what is specific to one. Each statement there links the source it comes from. This section explains the decisions behind it.

Web

iOS

  • A stepper is a two-segment control that increases or decreases an incremental value, next to a field that shows it: the iOS counterpart of the spin control (Apple HIG: Steppers). The small and medium sizes fall under the 44 by 44 pt hit region today (Apple HIG: Accessibility, mobility).

Android

  • Text field (text, including numbers that are text)
  • Slider (a value in a range)