Skip to main content
K
Last modified: 24/Jun/2024

Number input

The number input is a number specific input type. Use it when you need numerical data from the user.

#Usage

import { NumberInput } from '@kinsta/stratus' const MyComponent = () => ( <NumberInput steps={10} label="Type a number" /> )

Controlled example:

import type { JSX } from 'react' import { useState } from 'react' import { NumberInput } from '@kinsta/stratus' const MyComponent = (): JSX.Element | null => { const [inputValue, setInputValue] = useState(0) return ( <NumberInput value={inputValue} onChange={setInputValue} /> ) }

#Props

#steps
number
The incrementation applied by the +/- buttons
1
#onChange
(value: number | "") => void
Use to get the value of the number input
#value
number | ""
The value of the input
#isDisabled
boolean
Set the disabled state of input
#hasAutoFocus
boolean
Set that the input should be focused when rendered
#hasError
boolean
Set the error state of the input
#prefixItem
ReactNode
Content of the prefix of the input
#suffixItem
ReactNode
Content of the suffix of the input
#label
string | ReactElement<any, string | JSXElementConstructor<any>>
Content of the label
#description
string | ReactElement<any, string | JSXElementConstructor<any>>
Content of the description
#errorMessage
string | ReactElement<any, string | JSXElementConstructor<any>>
Content of the error message
#unit
string
Sets the unit of the input

#Types

  • NumberInputInterface: props of the NumberInput component extended by Omit<InputInterface, 'type' | 'isReadOnly' | 'onChange' | 'addonBefore' | 'addonAfter'>

Read more about types here


#See also