Balance Logo
Balance
Reckon Design System
Open playroom

Currency Input

An input to allow users to enter an amount of currency.
Install
pnpm add @balance-web/currency-input
Import usage
import {
CurrencyInput
} from '@balance-web/currency-input';
  • Code
  • API

Alternatives

  • TextInput — For single-line text input
  • Textarea — For multi-line text input
  • DurationInput — For amount of time input
  • SearchInput — For search input
  • SearchInput — For search input

Usage

The CurrencyInput is similar to the TextInput with a couple of small differences. The type of the value is string | number so it can be a string or a number. We represent a valid value as a number and everything else as a string. This makes it easy to pass the value to other systems that accept a float but means that we can still represent invalid values as strings so that validation errors can be shown when the value can't be represented as a number. We'll also format the value of the input using Intl.NumberFormat when the input is blurred.

It shares disabled, read only and validation states with TextInput.

Edit in Playroom

maximumFractionDigits

You can customise the maximum number of digits after the decimal place between 2(the default) and 4. The naming is based on the option that Intl.NumberFormat accepts.

showAdornment

You may choose to hide the dollar symbol adornment.

align

Sets the alignment of the value to left or right

Usage with @balance-web/forms

To use it with @balance-web/forms, you can combine validators to achieve the desired outcome.

Copyright © 2024 Reckon. Designed and developed in partnership with Thinkmill.
Bitbucket logoJira software logoConfluence logo