Components
Number Input
Field to enter and submit numeric input.
Import NumberInput
Tremor exports one component for number input.
import { NumberInput } from "@tremor/react";
Usage example
The example below shows number input examples with an icon
property,
error message
, no stepper buttons, and a disabled
state.
Number out of bounds
import { NumberInput } from "@tremor/react"; import { SearchIcon } from "@heroicons/react/solid"; export default () => ( <> <NumberInput icon={CurrencyDollarIcon} placeholder="Amount..." /> <NumberInput error={true} errorMessage="Number out of bounds" /> <NumberInput placeholder="Disabled" disabled={true} /> <NumberInput enableStepper={false} /> </> );
Theming
Number Input
Element | Theme Token |
---|---|
Roundness borderRadiustremor-default | |
Shadow boxShadowtremor-input | |
Font size fontSizetremor-default | |
Border color colorstremor-border-DEFAULT | |
Border color focus colorstremor-brand-subtle | |
Ring color focus colorstremor-brand-muted | |
Icon colorstremor-content-subtle | |
Background color colorstremor-background-DEFAULT | |
Background color disabled colorstremor-background-subtle | |
Background color hover colorstremor-background-muted | |
Text color placeholder colorstremor-content-DEFAULT | |
Text color input colorstremor-content-emphasis | |
Text color disabled colorstremor-content-muted |
API Reference: NumberInput
client component
- defaultValueoptional
- Description
- The default of NumberInput when it is initially rendered. Use when you do not need to control its state.
- Type
- string
- Default
- Values
- E.g. '1'
- valueoptional
- Description
- The controlled state of NumberInput. Must be used in conjunction with onChange.
- Type
- string
- Default
- Values
- E.g. '1'
- onValueChangeoptional
- Description
- Event handler called when the state of the input changes.
- Type
- (value: number) => void
- Default
- Values
- placeholderoptional
- Description
- Sets the placehoder text
- Type
- string
- Default
- Type...
- Values
- -
- iconoptional
- Description
- Set an icon.
- Type
- React.Element
- Default
- -
- Values
- erroroptional
- Description
- If true, the text input is labeled as invalid.
- Type
- boolean
- Default
- false
- Values
- true, false
- errorMessageoptional
- Description
- The text shown within a tooltip above the error icon if error property is set to true.
- Type
- string
- Default
- Values
- disabledoptional
- Description
- If true, the text input will be disabled.
- Type
- boolean
- Default
- false
- Values
- true, false
- stepoptional
- Description
- The step specifies the interval between legal numbers.
- Type
- number
- Default
- 1
- Values
- enableStepperoptional
- Description
- If false, the stepper buttons won't be shown.
- Type
- boolean
- Default
- true
- Values
- true, false
- minoptional
- Description
- Min specifies the minimum value for the input element.
- Type
- number
- Default
- Values
- maxoptional
- Description
- Max specifies the maximum value for the input element.
- Type
- number
- Default
- Values
Need help? You can also ask the community on GitHub Discussions or Slack.