Demos
Empty
<Field.Currency onChange={(value) => console.log('onChange', value)} />
Placeholder
<Field.Currency placeholder="Enter a number" onChange={(value) => console.log('onChange', value)} />
Label
<Field.Currency label="Amount" currencyDisplay="name" onChange={(value) => console.log('onChange', value)} />
Label and value
<Field.Currency value={150000} currency="NOK" label="Amount" onChange={(value) => console.log('onChange', value)} />
Exclusive minimum and exclusive maximum
<Field.Currency value={1000} label="Label text" allowNegative={false} required exclusiveMinimum={900} exclusiveMaximum={1000} validateInitially />
With step controls
<Field.Currency showStepControls label="Amount" minimum={500} maximum={2000} value={1000} step={100} />
Locale
This field is using NOK when locale is en-GB.
<Provider locale="en-GB"> <Field.Currency value={-150000} align="right" /> </Provider>
With help
<Field.Currency value={150000} currency="NOK" label="Amount" help={{ title: 'Help is available', content: 'Helping others, without expecting anything in return is what true self-worth is all about.', }} onChange={(value) => console.log('onChange', value)} />
Disabled
<Field.Currency value={25000000} label="Label text" onChange={(value) => console.log('onChange', value)} disabled />
Error
This is what is wrong...
<Field.Currency value={12345678} label="Label text" onChange={(value) => console.log('onChange', value)} error={new Error('This is what is wrong...')} />
Validation - Required
<Field.Currency label="Label text" onChange={(value) => console.log('onChange', value)} required validateInitially />
With Field.SelectCurrency
This example demonstrates how to use Field.Currency together with Field.SelectCurrency.
It imitates a transaction, and therefore sets the HTML autofill attribute for both fields, transaction-currency in Field.SelectCurrency and transaction-amount in Field.Currency.
<Form.Handler onSubmit={console.log}> <Form.Card> <Flex.Horizontal> <Field.SelectCurrency label="Select a currency" path="/currency" value="EUR" autoComplete="transaction-currency" /> <Field.Currency label="Amount" currency="/currency" autoComplete="transaction-amount" /> </Flex.Horizontal> </Form.Card> <Form.SubmitButton text="Pay" /> </Form.Handler>