Number input
Examples
Expanded version
Web Component
JavaScript
This component accepts options to configure its behavior.
Preventing memory leaks
Input number components have a dispose function to free all resources attached to the element, such as event listeners and object data. You should call this method when you want to remove the component.
TipIt is safe to call the numberInput
method more than once, as it will return any previously created number input component associated to the input.
Accessibility
Keyboard Navigation
Key | Function |
---|---|
Tab | Moves focus to the next focusable element. |
Shift + Tab | Moves focus to the previous focusable element. |
Up Arrow orShift +Up Arrow | Increases the value. |
Down Arrow orShift +Down Arrow | Decreases the value. |
Enter | Submits the entered value. |
For comprehensive details on keyboard support, refer to our Keyboard Control Guide.
Visit WebAIM for keyboard techniques.
Find live examples of accessible inputs with different types in DigitalA11y project.
Resources
- Mozilla Resources for Developers:Information about the HTML
input-type="number"
- A11y style guide:Describes core principles for the accessible inputs and textarea.
- MagentaA11y:How to test a number input.
Other recommendations
Explore additional accessibility tips in the general Accessibility Guide.
WCAG 2.2 Guidelines
- Non-text Content:All non-text content that is presented to the user has a text alternative that serves the equivalent purpose. (Level A)
- Info and Relationships:Information, structure, and relationships conveyed through presentation can be programmatically determined or are available in text. (Level A)
- Headings and Labels:Headings and labels describe topic or purpose. (Level AA)
- Labels or Instructions:Labels or instructions are provided when content requires user input. (Level A)
- Name, Role, Value:For all user interface components (including but not limited to: form elements, links and components generated by scripts), the name and role can be programmatically determined; states, properties, and values that can be set by the user can be programmatically set; and notification of changes to these items is available to user agents, including assistive technologies. (Level A)