v1.0.8

Float Input

Installation

Install yarn add @spark-web/float-input
Source GitHub.com
Bundle unpkg.com

Float input provides a way for inputting float values.

Usage

Field

The component must be nested within a Field. See Field for more details.

Examples

Controlled

A FloatInput can be either controlled or uncontrolled. To control a FloatInput provide a value, as well as an onChange function to set the new value when the select is updated.

The current value is: 1000000.101

Validation

The provided controlled value can be of type string or number. Valid numbers are represented as numbers and everything else as a string. This allows for easy passing of floats to other system, whilst also giving a way to check for invalid string values and provide an appropriate validation error.

Please provide a valid float input
The current value is: Hi there
The value type is: string

Uncontrolled

A FloatInput can also be uncontrolled, managing it's own internal state. To access the value, instead of writing an onChange handler, you would use a ref to get form values from the DOM.

The input value is:

Format fraction digits

You can also set to what fraction digit you want the displayed value in the FloatInput to be.

The current value is: 10000.101

Input Adornments

Similar to TextInput, you can also add adornments to the FloatInput component (at the start or end).

kW
The current value is: 10000.101

Props

PropTypeDescription

children?

AdornmentsAsChildren: ReactElement<InputAdornmentProps, string | JSXElementConstructor<any>> | [ReactElement<InputAdornmentProps, string | JSXElementConstructor<any>>, ReactElement<InputAdornmentProps, string | JSXElementConstructor<...>>]

Adorn the input with ornamental element(s) to aid user input, or

interactive element(s) to augment user input. Each child **must** be

wrapped with the `InputAdornment` component to ensure proper layout,

otherwise it will not be rendered.

data?

DataAttributeMap

Sets data attributes for the element.

fractionDigits?

number

Specifies to what fraction digit will be displayed in the component.

onChange?

(value: string | number) => void

value?

string | number

Additional props also include TextInput props which are not listed here.

© 2023 Brighte Capital Pty Ltd