Form Group

The Form Group component helps to structure and manage form input elements by providing a label, description, error message, and additional controls.

Usage

Default

<FormGroup label="Vertical" id="layout-vertical" layout="vertical">
  <TextInput value={value} onChange={(nextValue) => setValue(nextValue)} />
</FormGroup>
<FormGroup label="Horizontal" id="layout-horizontal" layout="horizontal">
  <TextInput value={value} onChange={(nextValue) => setValue(nextValue)} />
</FormGroup>

Props

Data table
TypeDescription
aria-describedbystringOptional override for the wrapper aria-describedby.
aria-labelstringOptional aria-label for the wrapper group.
aria-labelledbystringOptional override for the wrapper aria-labelledby.
childrenReactElement<unknown, string | JSXElementConstructor<any>> | ReactElement<unknown, string | JSXElementConstructor<...>>[]The form element or component (input, textarea, etc.).
classNamestringAdditional class names for styling.
controllerReactNodeOptional controller element (e.g., button, icon) beside input.
data-testidstringOptional test ID for testing frameworks.
descriptionstringOptional helper text displayed below the input.
errorstringOptional error message shown below the input.
hideLabelbooleanIf true, visually hides the label but keeps it accessible.
idstringUnique ID for the input and label association.
labelstringLabel for the input field.
layout"horizontal" | "vertical"Layout style for label and input. "vertical" (default) or "horizontal"
requiredbooleanWhether the field is required (adds asterisk).
roleAriaRoleOptional role for the wrapper. Defaults to "group".
spacingSizeTypeSpacing size between each input in the form group. ('xs' | 'small' | 'medium' | 'large' | 'xl')