Norsk Tipping Design System

NumberInput

NumberInput is a utility part of Slider

Install

yarn add @ntds/slider

Import

import { Slider } from '@ntds/slider';

Props

PropTypeDefaultDescription
namestringThe name of the input. Mainly used to make the internal id of the component unique
valuenumberUsed together with `onChange` to control the input-component like a [controlled component](https://reactjs.org/docs/forms.html#controlled-components).
minnumberMinimum number value possible to input.
maxnumberMaximum number value possible to input.
stepnumberStep value for arrow up/down usage. Default sett to 1. In addition, 'home' or the 'end' keys set the minimum or maximum value.
onChange(nextValue: number) => voidCalled for every value change. Typically for updating the value externally. **Important!** The NumberInput will return NaN on ALL invalid input (empty values, too big/small values and letters). If the value becomes invalid, the component will display an error message that you provide via the `errorMessage`-prop. Use `Number.isNaN(value)` to check if the input is valid.
label?string | ((info: InfoProps) => string)Label for the (actual) number input.
ariaValueText?(value: number) => stringProvide a more semantic read-out when the value change for screen readers For example: "1 uke", "2 uker" or "4 kuponger"
errorMessage?(info: InfoProps) => stringIf the user provides a invalid, too big/small or empty value, an inline error message will be shown under input. Provide a contextual message with the correct range (use the `info`-object to get the `min`, `max` values, for example)
showFocusMessage?booleanTo turn on focus message.
valueLabel?stringLabel for the (actual) number input.
fontSizeClass?stringFontSize class to override default.
tabIndex?number0Set to -1 if numberInput should be taken out of tab order.
tw?TwGroupKeysTailwind overrides

On this page