Park UI

Number Input

A form input component for entering and adjusting numeric values.

Installation

Usage

Info

If you prefer a closed component composition, check out the snippet below.

Shortcuts

The NumberInput component provides a set of shortcuts for common use cases

NumberInput.Control

This component renders the NumberInput.IncrementTrigger and NumberInput.DecrementTrigger within it by default.

Writing this:

is shorthand for writing this if you don't need to customize the triggers:

Examples

Sizes

Pass the size prop to change the size of the number input.

Formatting

Pass the formatOptions prop to format the number input value. The value of this maps to Intl.NumberFormatOptions and is applied based on the current locale.

Min and Max

Pass the min and max props to set the minimum and maximum values of the number input.

If value entered is less than min or greater than max, the value will be clamped to the nearest boundary on blur, or enter key press.

Step

Pass the step prop to change the increment or decrement interval of the number input.

Controlled

Pass the value and onValueChange props to control the value of the number input.

Mouse Wheel

Pass the allowMouseWheel prop to enable or disable the mouse wheel to change the value of the number input.

Disabled

Pass the disabled prop to disable the number input.

Invalid

Use the Field component and the invalid prop to indicate that the number input is invalid.

The entry is invalid

Helper Text

Compose the Field and Field.HelperText components to add helper text to the number input.

Please enter a number between 5 and 50

Element

Here's an example of how to compose the number input with the input group component to add an element on either the left or right.

Scrubber

Use the NumberInput.Scrubber component to make the number input supports scrubber interactions.

Closed Component

Here is an example of how to use the NumberInput component in a closed manner.

and use it like this:

Props

Root