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>

Visual variants

States

success
Enter your email.
warning
Enter your email.
error
Enter your email.
info
Enter your email.
visual-variants.tsx
// States
         <FormField state="success"
              label="Email"
              helperText="Enter your email."
    invalid
    errorMessage="This is a validation error."
            >
              <TextInput
                title="email"
                type="email"
                placeholder="name@example.com"
              />
            </FormField>
         <FormField state="warning"
              label="Email"
              helperText="Enter your email."
    invalid
    errorMessage="This is a validation error."
            >
              <TextInput
                title="email"
                type="email"
                placeholder="name@example.com"
              />
            </FormField>
         <FormField state="error"
              label="Email"
              helperText="Enter your email."
    invalid
    errorMessage="This is a validation error."
            >
              <TextInput
                title="email"
                type="email"
                placeholder="name@example.com"
              />
            </FormField>
         <FormField state="info"
              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>>Yesprops—Content rendered inside the component.
classNamestringNostyling—Additional CSS class names for the component root.
controlClassNamestringNoprops—Additional CSS class names for the control section.
data-testidstringNotesting—Test id used to identify the component in tests.
errorClassNamestringNoprops—Additional CSS class names for the error section.
errorMessageReactNodeNoprops—Error message or error state displayed with the component.
helperTextReactNodeNoprops—Helper text displayed with the field.
helperTextClassNamestringNoprops—Additional CSS class names for the helper text section.
idstringNoprops—HTML id applied to the relevant element.
invalidbooleanNoprops—-
labelReactNodeNoprops—Visible label content for the component.
labelClassNamestringNoprops—Additional CSS class names for the label section.