Currency
import Currency from 'frui/fields/Currency';Props
The following props are accepted by Currency.
| Name | Type | Required | Notes |
|---|---|---|---|
| className | string | No | Standard HTML class names |
| defaultValue | string | No | Alias to value |
| error | string|boolean | No | Any error message |
| name | string | No | Used for react server components. |
| onDropdown | Function | No | Event handler when dropdown opens/closes |
| onSelected | Function | No | Event handler when an option has been selected |
| onUpdate | Function | No | Update event handler |
| options | string[] | No | List of select options. |
| placeholder | string | No | Display text when no value set |
| searchable | boolean | No | Add a search field |
| style | CSS Object | No | Standard CSS object |
| value | string | No | Selected value from the options |
Basics
The following is a basic example of an聽Currency field.
<Currency className="w-full z-30 text-black" placeholder="Select Currency" searchable />Events
The following example makes use of all the possible events for 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))}
/>On Dropdown
The onDropdown event is triggered when the dropdown opens or closes. The following arguments are passed to the event handler:
| Name | Type | Sample |
|---|---|---|
| open | boolean | true |
On Selected
The onSelected event is triggered when an option has been selected. The following arguments are passed to the event handler:
| Name | Type | Sample |
|---|---|---|
| option | SelectOption | |
On Update
The onUpdate event is triggered when the value has been updated. The following arguments are passed to the event handler:
| Name | Type | Sample |
|---|---|---|
| value | CurrencyData | |
Custom Styles
You can add your own custom class to selects or use any of the respective聽frui-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, and聽frui-field-select-label CSS classes.
Errors
You can pass the error prop to highlight the Currency field red.
<Currency className="w-full z-10 text-black" error={string|true} value="US" />