CenturyLink
Lumen
Lumen Enterprise Portal
  • Getting Started
    • Introduction
    • Installation
    • Development workflow
    • Browser support
    • What's new
  • Foundations
      • Overview
      • Using the keyboard
      • Page structure
      • Color and sensory
      • Images
      • Text
      • Links and forms
      • Tables
      • Other
      • Color
      • Design tokens
      • Grid
  • Components
    • Accordion
    • Activity
    • Alert
    • Avatar
    • Badge
    • Brand
    • Breadcrumb
    • Button
    • Button group
    • Cache Loader
    • Card
    • Carousel
    • Checkbox
    • Copy text
    • Data table
    • Date picker
    • Divider
    • Drawer
    • Dropdown
    • Expansion panel
    • File input
    • Flag icon
    • Footer
    • Header
    • Icon
    • Label
    • Link
    • Marketing icon
    • Mobile navigation
    • Modal
    • Number input
    • Pagination
    • Phone Input
    • Picker
    • Picker group
    • Popover
    • Price
    • Progress
    • Radio button
    • Range slider
    • Search input
    • Select
    • Sidenav
    • Skeleton
    • Spinner
    • Stat
    • Steps
    • Table
    • Tabs
    • Tags
    • Text input
    • Textarea
    • Time picker
    • Toggle switch
    • Toolbar
    • Tooltip
    • Transfer list
  • Utilities
    • Border
    • Color
    • Display
    • Flex
    • Image
    • Opacity
    • Overflow
    • Position
    • Shadow
    • Sizing
    • Spacing
    • Text
    • Vertical-align
    • Z-index
  • Templates
    • App Layout
    • Card
    • Error 404
    • Error 500
    • State

Number input

Number inputs are used to increase or decrease numeric values.
  • Examples
  • Properties
  • Accessibility

Examples

Expanded version

Web Component

JavaScript

This component accepts options to configure its behavior.

Option
Default
Description
autofix
false
Fixes automatically values that are out of range of defined by max and min attributes, and any value that doesn't fit the granularity defined by step and the initial value

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

KeyFunction
TabMoves focus to the next focusable element.
Shift + TabMoves focus to the previous focusable element.
Up ArroworShift+Up ArrowIncreases the value.
Down ArroworShift+Down ArrowDecreases the value.
EnterSubmits the entered value.

For comprehensive details on keyboard support, refer to our Keyboard Control Guide.

Visit WebAIM for keyboard techniques.

Guidance for developers
  • Ensure simplicity since not all browsers handle multiple labels linked to the same form element correctly.
  • Label Usage: Assign a label to each input field and make sure the for="" attribute of the label matches the id="" of the corresponding input. Remember, each id must be unique on the page, and each form element should have only one associated label.
  • Indicating Required Fields: Clearly mark required fields using indicators like an asterisk (*) or descriptive text to make them easily identifiable.
  • Help Text: Incorporate help text for all form fields, especially those with constraints. This text should be programmatically associated with the input, for example, using aria-describedby. This is particularly important for masked fields.
  • Test compatibility with various screen readers (like JAWS, NVDA, or VoiceOver) to ensure the number input component is announced correctly. Options should be clearly read out when navigated.
  • Error Validation: Fields with validation errors should use aria-describedby to ensure that error messages are accessible to assistive technologies. If an error message has an id="my-error-message", the corresponding input should include aria-describedby="my-error-message"
Guidance for designers
  • Design with simplicity to accommodate all browsers, minimizing complexities that could hinder accessibility.
  • Obvious Required Fields: Use visual cues, such as an asterisk (*) or supplementary text, to clearly mark required fields and make them easily distinguishable.
  • User-Friendly Help Text: Place help text or examples directly below or inside the number input field to guide users on the correct format.
  • Visible Error Feedback: Design error messages to appear clearly near the number input field when validation fails, using color, icons, or text to make them noticeable.
  • Sufficient Tap Targets: Ensure number input fields have large enough tap targets to accommodate users with different levels of dexterity, following touch-friendly design principles.
  • Use spacing, typography, and visual cues effectively.
  • Maintain consistency in the design of the number input to provide a cohesive user experience.

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)