Balance Logo
Balance
Reckon Design System

Currency Field

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

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.

""string
$
Open 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.

CurrencyField

If you're using the CurrencyInput inside a form, you should use the CurrencyField component. This accepts similar props to other Field components.

$

Usage with @reckon-web/forms

To use it with @reckon-web/forms, you can use field.currency and validate.currency.

$
Copyright © 2021 Reckon. Designed and developed in partnership with Thinkmill.