.finally(React)

English
Copyright © 2023-currentdotfinally, LLC

Number Input

Number, Currency, and Percent Formatting

The Text Input component can be used by importing { TextInput } from "finallyreact"

It uses three main types: 'number', 'currency', and 'percent', which can each display formatted input values based on a given locale (like 'en-US') and a given currency (like 'USD'). Input values are emitted through onBlur and onChange events (or the generic onEvent prop, which combines both). Values input should always be numbers, what's displayed will be a formatted string, and both the formatted and unformatted values will be output (as e.target.value and e.target.formattedValue).

Note: If decimal props are not defined, the default number of decimals for the formatted value will vary based on type, locale, and currency.

  • For currency: default decimals will be 2 for USD and vary for other currencies.
  • For number: default decimals will be maximum 3.
  • For percent: default decimals will be 0.

Parameters

Changing these parameters will update all examples below

Number
Type
Locale
Currency
Round
min decimals
max decimals
decimals
min value
max value

Example

Event:
Value:
Number Input: Example

Outline

Event:
Value:
Number Input: Outline

Rounded

Event:
Value:
Number Input: Rounded

Clear Icon

Event:
Value:
Event:
Value:
Number Input: Clear Icon

Placeholder - Floating

Float
Event:
Value:
Float
Event:
Value:
Number Input: Placeholder - Floating

Placeholder - Not Floating

No Float
Event:
Value:
No Float
Event:
Value:
Number Input: Placeholder - Not Floating

Color

Event:
Value:
Event:
Value:
Event:
Value:
Number Input: Color

Size

small
Event:
Value:
medium
Event:
Value:
large
Event:
Value:
small
Event:
Value:
medium
Event:
Value:
large
Event:
Value:
Number Input: Size

Disabled

9,001
Placeholder
Number Input: Disabled

Simple

Event:
Value:
Number Input: Simple

Left and Right Icons

🦙
Placeholder
Placeholder
🍏
Number Input: Left and Right Icons

Left and Right Labels

Left Label
Placeholder
Placeholder
Right Label
Number Input: Left and Right Labels

Custom Clear Icon

Number Input: Custom Clear Icon

NumberInput Props

Prop NameProp TypeDescription
clearPropsHTMLAttributesProps for clear icon
colorstringAny FinallyReact color
currencystringCurrency code (like 'USD' or 'GBP')
customClearReact.ReactNodeCustom clear component
decimalsnumberAlways have this many decimals
disabledbooleanDisable input
disableFormatbooleanDisable formatting
floatingPlaceholderbooleanFloat placeholder when input is not empty
initialValuenumberInitial value for input
inputPropsHTMLAttributesProps for inner input
labelPropsHTMLAttributesProps for left and right labels
leftIconanyIcon to show on left side of input
leftLabelstringLabel to show on left side of input
leftLabelPropsHTMLAttributesProps for left label
localestringLocale for formatting
maxnumberMaximum value
maxDecimalsnumberMaximum number of decimals
minnumberMinimum value
minDecimalsnumberMinimum number of decimals
namestringName for input
onClear() => voidCallback for clear icon
outlinebooleanOutline input
placeholderstringPlaceholder for input
readOnlybooleanMake input read only
rightIconanyIcon to show on right side of input
rightLabelstringLabel to show on right side of input
rightLabelPropsHTMLAttributesProps for right label
round"round" | "ceil" | "floor" | "truncate"Modify values based on rounding rules; takes precedence over decimals
roundedbooleanRound input
showClearbooleanShow clear icon
simplebooleanSimple input with no styles
sizesm | md | lgSize of input
type"number" | "currency" | "percent"Type of formatting
valuenumberValue for input