Documentation
Form Components
Amount Input

Amount Input

The AmountInput component is a customizable input field designed for users to enter numerical amounts, featuring validation and formatting options.

Installation

Install the package

npm i @start-base/react-form-elements

Add the styles

To use the React form elements styles in a Next.js project, import the styles in your layout.tsx file.

app/layout.tsx
import "@start-base/react-form-elements/styles.css";

Import the component

import AmountInput from '@start-base/react-form-elements/AmountInput';

Usages

Amount Input Without Label

Amount Input With Floating Label

Amount Input With Placeholder

Amount Input With Floating Label and Placeholder

Amount Input With Placeholder And Disable Shrink

Disabled Amount Input

Amount Input With Append

Amount Input With Prepend

Amount Input With Error Message

Error Message

Amount Input With Error

API

This component is a wrapper around react-currency-input-field (opens in a new tab) component. All props from react-currency-input-field can be passed to this component.

NameTypeDefaultDescription
namestringName of the input
labelstringnullLabel of the input
placeholderstringnullPlaceholder of the input
disableShrinkbooleanfalsePosition the label outside of the input
valuenumberValue of the input
onChangefunctionCallback function that is fired when the value changes.
inputClassNamestringnullClassname for input element
labelClassNamestringnullClassname for label element
errorClassNamestringnullClassname for error element
disabledbooleanfalseDisable the input
errorstring or boolean or objectnullError message to display below the input. if value is a boolean input border will be change. Also you can pass schema validator error objects.
prependstring or elementnullPrepend text to the input
appendstring or elementnullAppend text to the input
appendClassNamestringnullClassname for append element
prependClassNamestringnullClassname for prepend element
allowDecimalsbooleantrueAllow decimals
allowNegativeValuebooleantrueAllow user to enter negative value
decimalsLimitnumber2Limit length of decimals allowed
decimalScalenumberSpecify decimal scale for padding/trimming eg. 1.5 -> 1.50 or 1.234 -> 1.23 if decimal scale 2
fixedDecimalLengthnumberValue will always have the specified length of decimals
prefixstringInclude a prefix eg. ÂŁ or $
suffixstringInclude a suffix eg. € or %
decimalSeparatorstringlocale defaultSeparator between integer part and fractional part of value
groupSeparatorstringlocale defaultSeparator between thousand, million and billion
intlConfigobjectInternational locale config
disabledbooleanfalseDisabled
disableAbbreviationsbooleanfalseDisable abbreviations eg. 1k -> 1,000, 2m -> 2,000,000
disableGroupSeparatorsbooleanfalseDisable auto adding the group separator between values, eg. 1000 -> 1,000
maxLengthnumberMaximum characters the user can enter
stepnumberIncremental value change on arrow down and arrow up key press
transformRawValuefunctionTransform the raw value from the input before parsing. Needs to return string.