Number Input

<wa-number-input> Stable Since 3.2

Number inputs let users enter and edit numeric values, with optional stepper buttons for incrementing and decrementing. Use them for quantities, measurements, and other numeric form fields.

This component works with standard <form> elements. Please refer to the section on form controls to learn more about form submission and client-side validation.

Examples

Link to This Section

Labels

Link to This Section

Use the label attribute to give the input an accessible label. For labels that contain HTML, use the label slot instead.

Hint

Link to This Section

Add descriptive hint to an input with the hint attribute. For hints that contain HTML, use the hint slot instead.

Placeholders

Link to This Section

Use the placeholder attribute to add a placeholder.

Setting Min, Max, and Step

Link to This Section

Use the min and max attributes to set a minimum and maximum value. Use the step attribute to change the granularity the value must adhere to when using the stepper buttons or arrow keys.

Appearance

Link to This Section

Use the appearance attribute to change the input's visual appearance.



Disabled

Link to This Section

Use the disabled attribute to disable an input.

Readonly

Link to This Section

Use the readonly attribute to make the input readonly. The value can still be selected and copied, but it cannot be changed.

Sizes

Link to This Section

Use the size attribute to change an input's size.





Pill

Link to This Section

Use the pill attribute to give inputs rounded edges.





Without Steppers

Link to This Section

Add the without-steppers attribute to remove the increment/decrement buttons. Users can still modify the value using the keyboard.

When steppers are hidden, users can still use the arrow keys to increment and decrement the value.

Start & End Decorations

Link to This Section

Use the start and end slots to add presentational elements like <wa-icon> within the input.


Custom Stepper Icons

Link to This Section

Use the increment-icon and decrement-icon slots to customize the stepper button icons.

Customizing Label Position

Link to This Section

Use CSS parts to customize the way form controls are drawn. This example uses CSS grid to position the label to the left of the control, but the possible orientations are nearly endless. The same technique works for inputs, textareas, radio groups, and similar form controls.

Form Validation

Link to This Section

Use the required attribute to make the field required. Combine with min and max for range validation.



Submit Reset

Importing

Link to This Section

If you're using the autoloader or a hosted project, components load on demand — no manual import needed. To cherry-pick a component manually, use one of the following snippets.

CDN npm Self-Hosted React

Import this component directly from the CDN:

import 'https://ka-f.webawesome.com/[email protected]/components/number-input/number-input.js';

After installing Web Awesome via npm, import this component:

import '@awesome.me/webawesome/dist/components/number-input/number-input.js';

If you're self-hosting Web Awesome, import this component from your server:

import './webawesome/dist/components/number-input/number-input.js';

To import this component for React 18 or below, use the following code:

import WaNumberInput from '@awesome.me/webawesome/dist/react/number-input/index.js';

Slots

Link to This Section

Learn more about using slots.

Attributes & Properties

Link to This Section

Learn more about attributes and properties.

Methods

Link to This Section

Learn more about methods.

Events

Link to This Section

Learn more about events.

Custom States

Link to This Section

Learn more about custom states.

CSS parts

Link to This Section

Learn more about CSS parts.

Dependencies

Link to This Section

This component automatically imports the following elements. Sub-dependencies, if any exist, will also be included in this list.

Need a hand? Report a bug Ask for help
    No results