Native Web Components playground

Nova v3.37.0

Preview

Web Components

Number field

nv-fieldnumber

A form field for typing a number or adjusting it with minus and plus buttons.

Live demo

Size

Use a number field for a precise numeric value, such as a quantity, an amount or a limit. People can type the number or change it with the stepper. To pick a value along a range, use a slider.

Anatomy

A number field with four callouts: 1 marks the label Field label, 2 the input showing the placeholder 00, 3 the description below it, and 4 the minus and plus buttons at the right end of the input.

The parts of a number field.
  1. Label (optional) names the number to enter.
  2. Input accepts the number. A unit or icon can sit before it in the leading-input slot.
  3. Description (optional) states the allowed values.
  4. Stepper buttons lower or raise the value by step; the arrow keys do the same in the input. hideActions removes the stepper.

Values and limits

The value is a number, or null when the input is empty. min and max disable the stepper buttons at each limit, but they do not stop people from typing other numbers, so validate the value in your application.

min="1"
max="10"
hideActions

States

Hover and focus styles are built in. required marks the label with an asterisk; disabled and read-only fields also lock the stepper. Set error with an errorDescription to explain an invalid number, or success to confirm a valid one.

readonly
error
success

Size

Use size="sm" for a 32 px field or size="md" for the default 40 px field. The field is capped at 480 px; fluid lets it fill a wider container.

Validation feedback

An error combines a red outline, warning icon and explanatory message. Success uses a green outline and check icon. Show these only after your application has checked the number, including its allowed range and step.

Themes

The design includes Spark and Ocean appearances. Use the page's theme and mode controls to compare the live examples; retain the same labels, states and validation messages in each theme.

Guidelines

  • Name the quantity in the label, such as "Number of tickets".
  • State limits and steps in the description, such as "Up to 500 entries".
  • Leave out instructions that add nothing, such as "Type a number".
DoName the quantity and state its limits.
Don'tAvoid labels that only tell people to type a number.

Sources