Description
Field.CountryCode
is a wrapper component for the autocomplete component, with options built in for selecting a country code.
import { Field } from '@dnb/eufemia/extensions/forms'render(<Field.CountryCode />)
Demos
Empty
Code Editor
<Field.CountryCodeonFocus={(value) => console.log('onFocus', value)}onBlur={(value) => console.log('onBlur', value)}onChange={(value) => console.log('onChange', value)}/>
Placeholder
Code Editor
<Field.CountryCodeplaceholder="Code?"onChange={(value) => console.log('onChange', value)}/>
Label
Code Editor
<Field.CountryCodelabel="Label text"onChange={(value) => console.log('onChange', value)}/>
Option selected
Code Editor
<Field.CountryCodevalue="+47"onChange={(value) => console.log('onChange', value)}/>
Label and option selected
Code Editor
<Field.CountryCodevalue="+46"label="Label text"onChange={(value) => console.log('onChange', value)}/>
With help
Code Editor
<Field.CountryCodevalue="+45"label="Label text"help={{title: 'Help is available',contents:'Helping others, encouraging others, are often acts of being kind that have more meaning that you may realize.',}}onChange={(value) => console.log('onChange', value)}/>
Horizontal layout
Code Editor
<Field.CountryCodelayout="horizontal"value="+45"label="Label text"onChange={(value) => console.log('onChange', value)}/>
Widths
Code Editor
<Field.CountryCodevalue="+45"label="Default width (prop omitted"onChange={(value) => console.log('onChange', value)}/><Field.CountryCodevalue="+45"label="Small"width="small"onChange={(value) => console.log('onChange', value)}/><Field.CountryCodevalue="+45"label="Medium"width="medium"onChange={(value) => console.log('onChange', value)}/><Field.CountryCodevalue="+45"label="Large"width="large"onChange={(value) => console.log('onChange', value)}/><Field.CountryCodevalue="+45"label="Stretch"width="stretch"onChange={(value) => console.log('onChange', value)}/>
Disabled
Code Editor
<Field.CountryCodevalue="+44"label="Label text"onChange={(value) => console.log('onChange', value)}disabled/>
Error
Code Editor
<Field.CountryCodevalue="+43"label="Label text"onChange={(value) => console.log('onChange', value)}error={new FormError('This is what is wrong...')}/>
Validation - Required
Code Editor
<Field.CountryCodelabel="Label text"onChange={(value) => console.log('onChange', value)}requiredvalidateInitiallyvalidateUnchanged/>