Demos
Empty
<Field.String onChange={(value) => console.log('onChange', value)} />
Placeholder
<Field.Stringplaceholder="Enter a text..."onChange={(value) => console.log('onChange', value)}/>
Label
<Field.Stringlabel="Label text"onChange={(value) => console.log('onChange', value)}/>
Label and value
<Field.Stringlabel="Label text"value="foo"onChange={(value) => console.log('onChange', value)}/>
Horizontal layout
<Field.Stringlabel="Label text"value="foo"layout="horizontal"onChange={(value) => console.log('onChange', value)}/>
Widths
<Field.Stringlabel="Default width (property omitted)"value="foo"onChange={(value) => console.log('onChange', value)}/><Field.Stringlabel="False (for browser default)"value="foo"width={false}onChange={(value) => console.log('onChange', value)}/><Field.Stringlabel="Medium"value="foo"width="medium"onChange={(value) => console.log('onChange', value)}/><Field.Stringlabel="Large"value="foo"width="large"onChange={(value) => console.log('onChange', value)}/><Field.Stringlabel="Stretch"value="foo"width="stretch"onChange={(value) => console.log('onChange', value)}/>
Icons
<Field.Stringlabel="Icon left"value="foo"leftIcon="check"onChange={(value) => console.log('onChange', value)}/><Field.Stringlabel="Icon right"value="foo"rightIcon="loupe"onChange={(value) => console.log('onChange', value)}/>
Character counter
 0
<Field.StringonChange={(value) => console.log('onChange', value)}characterCounter/>
3
<Field.Stringlabel="Label text"value="foo"onChange={(value) => console.log('onChange', value)}characterCounter/>
3/16
<Field.Stringlabel="Label text"value="foo"onChange={(value) => console.log('onChange', value)}maxLength={16}characterCounter/>
Clear
<Field.Stringvalue="foo"onChange={(value) => console.log('onChange', value)}clear/>
Disabled
<Field.Stringvalue="foo"label="Label text"onChange={(value) => console.log('onChange', value)}disabled/>
Info
Useful information (?)
<Field.Stringvalue="foo"label="Label text"onChange={(value) => console.log('onChange', value)}info="Useful information (?)"/>
Warning
I'm warning you...
<Field.Stringvalue="foo"label="Label text"onChange={(value) => console.log('onChange', value)}warning={new FormError("I'm warning you...")}/>
Error
This is what is wrong...
<Field.Stringvalue="foo"label="Label text"onChange={(value) => console.log('onChange', value)}error={new FormError('This is what is wrong...')}/>
Validation - Required
<Field.Stringvalue="foo"label="Label text"onChange={(value) => console.log('onChange', value)}required/>
Validation - Minimum length
<Field.Stringvalue="foo"label="Label text (minimum 8 characters)"onChange={(value) => console.log('onChange', value)}minLength={8}/>
Validation - Maximum length and custom error message
<Field.Stringvalue="foo"label="Label text (maximum 8 characters)"onChange={(value) => console.log('onChange', value)}maxLength={8}errorMessages={{maxLength: "You can't write THAT long.. Max 8 chars!",}}/>
Validation - Pattern
<Field.Stringvalue="foo"label="Label text"onChange={(value) => console.log('onChange', value)}pattern="^foo123"/>
Synchronous external validator (called on every change)
<Field.Stringvalue="foo"label="Label text (minimum 4 characters)"validator={(value) =>value.length < 4 ? new FormError('At least 4 characters') : undefined}onChange={(value) => console.log('onChange', value)}/>
Asynchronous external validator (called on every change)
<Field.Stringvalue="foo"label="Label text (minimum 4 characters)"validator={(value) =>new Promise((resolve) =>setTimeout(() =>resolve(value.length < 5? new FormError('At least 5 characters'): undefined),1500))}onChange={(value) => console.log('onChange', value)}/>
Synchronous external validator (called on blur)
<Field.Stringvalue="foo"label="Label text (minimum 4 characters)"onBlurValidator={(value) =>value.length < 4 ? new FormError('At least 4 characters') : undefined}onChange={(value) => console.log('onChange', value)}/>
Asynchronous external validator (called on blur)
<Field.Stringvalue="foo"label="Label text (minimum 4 characters)"onBlurValidator={(value) =>new Promise((resolve) =>setTimeout(() =>resolve(value.length < 5? new FormError('At least 5 characters'): undefined),1500))}onChange={(value) => console.log('onChange', value)}/>
Multiline, empty
<Field.StringonChange={(value) => console.log('onChange', value)}multiline/>
Multiline, placeholder
<Field.Stringplaceholder="Enter text here"onChange={(value) => console.log('onChange', value)}multiline/>
Multiline, label & value
<Field.Stringvalue="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis in tempus odio, nec interdum orci. Integer vehicula ipsum et risus finibus, vitae commodo ex luctus. Nam viverra sollicitudin dictum. Vivamus maximus dignissim lorem, vitae viverra erat dapibus a."label="Label text"onChange={(value) => console.log('onChange', value)}multiline/>