Currency

import Currency from 'frui/fields/Currency';
Copy

Props

The following props are accepted by Currency.

NameTypeRequiredNotes
classNamestringNoStandard HTML class names
defaultValuestringNoAlias to value
errorstring|booleanNoAny error message
namestringNoUsed for react server components.
onDropdownFunctionNoEvent handler when dropdown opens/closes
onSelectedFunctionNoEvent handler when an option has been selected
onUpdateFunctionNoUpdate event handler
optionsstring[]NoList of select options.
placeholderstringNoDisplay text when no value set
searchablebooleanNoAdd a search field
styleCSS ObjectNoStandard CSS object
valuestringNoSelected value from the options

Basics

The following is a basic example of anCurrency field.

Select Currency
<Currency className="w-full z-30 text-black" placeholder="Select Currency" searchable />
Copy

Events

The following example makes use of all the possible events for Currency.

Choose a Currency
<Currency 
  className="w-full z-20 text-black" 
  onDropdown={open => console.log('dropdown', open)}
  onSelected={option => console.log('selected', option)}
  onUpdate={value => alert(JSON.stringify(value))}
/>
Copy

On Dropdown

The onDropdown event is triggered when the dropdown opens or closes. The following arguments are passed to the event handler:

NameTypeSample
openbooleantrue

On Selected

The onSelected event is triggered when an option has been selected. The following arguments are passed to the event handler:

NameTypeSample
optionSelectOption
{
  label: 'USD',
  value: {
    countryCode: 'US',
    countryName: 'United States',
    currencyType: 'fiat',
    currencyCode: 'USD',
    currencyName: 'US Dollar',
    currencyPlural: 'US Dollars',
    currencySymbol: '$',
    language: 'en'
  }
}

On Update

The onUpdate event is triggered when the value has been updated. The following arguments are passed to the event handler:

NameTypeSample
valueCurrencyData
{
  countryCode: 'US',
  countryName: 'United States',
  currencyType: 'fiat',
  currencyCode: 'USD',
  currencyName: 'US Dollar',
  currencyPlural: 'US Dollars',
  currencySymbol: '$',
  language: 'en'
}

Custom Styles

You can add your own custom class to selects or use any of the respectivefrui-field-select,frui-field-select-control,frui-field-select-placeholder,frui-field-select-dropdown,frui-field-select-search,frui-field-select-search-control,frui-field-select-search-icon,frui-field-select-options,frui-field-select-option, andfrui-field-select-label CSS classes.

Errors

You can pass the error prop to highlight the Currency field red.

Choose a Currency
<Currency className="w-full z-10 text-black" error={string|true} value="US" />
Copy