A form field is the fundamental element of a form. It combines an input, its label, and helper text if needed. An input can be anything from a text field to checkboxes or sliders.
You can take a look at all of our form control components here.
Anatomy
- Label: Represents a caption for an input in a form; you can learn more about them in our label documentation.
- Input: An element where the user can input data; there are exceptional cases where you can stack more than one input (Checkboxes/Radio buttons).
- Helper text(optional): A small paragraph that gives the user helpful context about the data they need to provide. We recommend not exceeding three lines of text for it. If you need more, we recommend adding a link that might open a modal or a side panel.
- Error text: A simple message notifying the user the data they added to the input was incorrect. It should be simple and straight to the point.
Styling
Spacing
Vertical Stacking
The gap between form controls should be 16px (forms-formControl-gap).
Horizontal Stacking
The gap between horizontally stacked form controls should be 16px (forms-formControl-gap).
Grouped Inputs (Checkbox & Radio button Groups)
If you have a radio button or checkbox group that requires more than one input, the gap between them should be 8px (forms-formControl-groupedInputs-gap).
Color & Text Styles
The color and text styles are on each component’s documentation page.