Number Input

The Number Input component is used to manage numeric input fields.

import { NumberInput } from '@cerberus/react'

Usage

The NumberInput component provides a way to create input fields specifically for numeric values. It includes features such as increment and decrement buttons, and can be easily integrated with form libraries.

Choose your quantity.

Scrubber

The NumberInput supports the scrubber interaction pattern. To use this pattern, use the scrubber prop. It uses the Pointer lock API and tracks the pointer movement. It also renders a virtual cursor which mimics the real cursor's pointer

Use your mouse wheel to change the value.

Sizes

The NumberInput component supports different sizes to accommodate various design requirements. You can specify the size using the size prop.

Primitives

You can utilize the primitive components or the css prop to customize the number input.

ComponentDescription
NumberInputRootThe context provider for the NumberInput parts
NumberInputLabelThe label of the NumberInput
NumberInputControlThe wrapper of the NumberInput contents
NumberInputInputThe input of the NumberInput
NumberInputIncrementTriggerThe increment button of the NumberInput
NumberInputDecrementTriggerThe decrement button of the NumberInput
NumberInputScrubberThe scrubber of the NumberInput

API

Props

The NumberInput component is an abstraction of the primitives and accepts the following props:

NameDefaultDescription
scrubberfalseUse scrubber controls for the number input.

The NumberInput component also accepts all the props of the NumberInputRoot primitive props

Parts

The NumberInputParts API is an Object containing the full family of components.

NameDescription
RootThe NumberInputRoot component which is the Provider for the family.
LabelThe NumberInputLabel component which displays the label and "required" notice.
InputThe NumberInputInput component which is the input field.
ControlThe NumberInputControl component which is the wrapper for the input and buttons.
IncrementTriggerThe NumberInputIncrementTrigger component which is the increment button.
DecrementTriggerThe NumberInputDecrementTrigger component which is the decrement button.
ScrubberThe NumberInputScrubber component which is the scrubber control.