Next to the properties listed in the propstable, a collection of system props can be added to any component for further general styling and layouting purposes. These props vary per component.
By default the TextField is always required. To make a TextField optional
you can add the optionalLabel prop.
With Chameleon we take a specific approach where we encourage marking optional
fields, not required. The majority of fields in a form are always required.
Indicating that fields are required make users more fearful, it increases the
risk of errors and reduces the form completion rate.
<TextField
id="optional-label"
label="Label"
placeholder="Placeholder"
optionalLabel="Optional"
/>
Error
default: undefined
To convey an error to the user, you can set the error prop to true.
For further illustration purposes, you can provide an iconLeft.
<TextField
id="icon-left"
label="Label"
placeholder="Placeholder"
iconLeft={Search}
/>
LabelHidden
default: undefined
To meet accessibility requirements, every TextField should have an associated
label. We do support the ability to visually hide the label when the TextField's
purpose is clear.
<TextField
id="label-hidden"
label="Label"
labelHidden
placeholder="Placeholder"
/>
Message
default: undefined
Give additional information to the user.
Multiple inputs should have space 5 between them.
Multiple inputs should have space 5 between them. Oh, we've got error.
<Boxmb={5}>
<TextField
id="message"
label="Label"
placeholder="Placeholder"
message="Multiple inputs should have space 5 between them."
/>
</Box>
<Box>
<TextField
id="message-1"
label="Label"
placeholder="Placeholder"
message="Multiple inputs should have space 5 between them. Oh, we've got error."
error
/>
</Box>
Mask
default: undefined
To visually aid the user with the expected format, you can use an input mask.
Input masks will display a template of the expected value. The mask is built out
of several definitions: