Form Field

The FormField component is a controlled input component with a label, helper text, and validation error. It provides a consistent structure for form inputs and helps to manage their state and validation.

Usage & Examples

Default

Enter your email.
default.tsx
         <FormField
              label="Email"
              helperText="Enter your email."
    invalid
    errorMessage="This is a validation error."
            >
              <TextInput
                title="email"
                type="email"
                placeholder="name@example.com"
              />
            </FormField>

Props API

17 props
Columns
Form Field props API
Default
Description
childrenReactElement<Record<string, unknown>, string | JSXElementConstructor<any>>YespropsContent rendered inside the component.
classNamestringNostylingAdditional CSS class names for the component root.
controlClassNamestringNopropsAdditional CSS class names for the control section.
data-testidstringNotestingTest id used to identify the component in tests.
errorClassNamestringNopropsAdditional CSS class names for the error section.
errorMessageReactNodeNopropsError message or error state displayed with the component.
helperTextReactNodeNopropsHelper text displayed with the field.
helperTextClassNamestringNopropsAdditional CSS class names for the helper text section.
idstringNopropsHTML id applied to the relevant element.
invalidbooleanNoprops-
labelReactNodeNopropsVisible label content for the component.
labelClassNamestringNopropsAdditional CSS class names for the label section.