Semantics

A form of range that expects the user to select from among discrete choices.

Additional info from the ARIA specification

A spinbutton typically allows users to change its displayed value by activating increment and decrement buttons that step through a set of allowed values. Some implementations display the value in an text field that allows editing and typing but typically limits input in ways that help prevent invalid values.

Although a spinbutton is similar in appearance to many presentations of select, it is advisable to use spinbutton when working with known ranges (especially in the case of large ranges) as opposed to distinct options. For example, a spinbutton representing a range from 1 to 1,000,000 would provide much better performance than a select widget representing the same values.

Authors MAY create a spinbutton with accessibility children, but MUST limit those elements to a textbox and/or two buttons. Alternatively, authors MAY apply the spinbutton role to a text input and create sibling buttons to support the increment and decrement functions.

To be keyboard accessible, authors SHOULD manage focus of descendants for all instances of this role, as described in Managing Focus. When a spinbutton receives focus, authors SHOULD ensure focus is placed on the textbox element if one is present, and on the spinbutton itself otherwise. Authors SHOULD also ensure the up and down arrows on a keyboard perform the increment and decrement functions and that the increment and decrement button elements are NOT included in the primary navigation ring, e.g., the Tab ring in HTML.

Authors SHOULD set the aria-valuenow attribute when the spinbutton has a value. Authors SHOULD set the aria-valuemin attribute when there is a minimum value, and the aria-valuemax attribute when there is a maximum value.

Abstract Role

  • WidgetRepresents a focusable, interactive element.

Content Categories

  • Phrasing ContentAn element that typically appears inline and provides semantic meaning to text content.

Allowed Descendants

Flow Children Allowed

No main element descendants allowed.

Usage

Allowed HTML elements

Implicit semantics

These elements have the role semantics by default, without needing to set the role attribute. Reach for elements with native semantics first when choosing how to implement a role in your content.

  • input­[type=­number]

Explicitly allowed

  • input­[type=­text][role=spinbutton]

Elements that can have any role

  • abbr[role=spinbutton]
  • address[role=spinbutton]
  • b[role=spinbutton]
  • blockquote[role=spinbutton]
  • canvas[role=spinbutton]
  • cite[role=spinbutton]
  • code[role=spinbutton]
  • custom-element[role=spinbutton]
  • data[role=spinbutton]
  • del[role=spinbutton]
  • dfn[role=spinbutton]
  • div[role=spinbutton]
  • em[role=spinbutton]
  • figure[role=spinbutton]
  • i[role=spinbutton]
  • ins[role=spinbutton]
  • kbd[role=spinbutton]
  • mark[role=spinbutton]
  • output[role=spinbutton]
  • p[role=spinbutton]
  • pre[role=spinbutton]
  • q[role=spinbutton]
  • samp[role=spinbutton]
  • small[role=spinbutton]
  • span[role=spinbutton]
  • table[role=spinbutton]
  • tbody[role=spinbutton]
  • tfoot[role=spinbutton]
  • thead[role=spinbutton]
  • time[role=spinbutton]
  • u[role=spinbutton]
  • var[role=spinbutton]