Live demo
Demo source
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.
- Label (optional) names the number to enter.
- Input accepts the number. A unit or icon can sit before it in the
leading-inputslot. - Description (optional) states the allowed values.
- Stepper buttons lower or raise the value by
step; the arrow keys do the same in the input.hideActionsremoves 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.
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.
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".