Skip to main content
A comprehensive form component built on React Hook Form with validation, field state management, and accessibility features.

Import

Component Parts

component
Root form element with context provider
component
Field wrapper with label, input, and error associations
component
Field with built-in Controller for complex inputs
component
Controller bound to parent Field context
component
Context consumer for field metadata
component
Accessible label element
component
Input field with automatic registration
component
Multi-line text input
component
Select dropdown input
component
Container for input with left/right items
component
Left-side addon for InputGroup
component
Right-side addon for InputGroup
component
Helper text for the field
component
Error message display
component
Form submit button
component
Watch form values with render props
component
Subscribe to form state changes

Form.Root

Root form element that provides form context to all child components.

Props

UseFormReturn<TFieldValues, unknown, TTransformedValues>
required
React Hook Form instance from useForm()
React.ReactNode
required
Child components
boolean | EyeIconObject
Configure password visibility toggle
  • true - Use default eye icon
  • false - Disable eye icon
  • Object with custom icons:
string
CSS class names for the form element. Default includes flex flex-col

Data Attributes

  • data-scope="form"
  • data-part="root"
  • data-slot="form-root"

Form.Field

Field wrapper that creates context for label, input, description, and error associations.

Props

FieldPath<TFieldValues>
required
Field name matching the form schema
Control<TFieldValues, unknown, TTransformedValues>
Form control (auto-resolved from context if not provided)
boolean
default:true
Whether to render a wrapper div
  • true - Render wrapper with default classes
  • false - Only provide context without wrapper
string
CSS class names when withWrapper is true. Default includes flex flex-col gap-2
React.ReactNode
required
Field content

Data Attributes (when withWrapper is true)

  • data-scope="form"
  • data-part="field"
  • data-slot="form-field"
  • data-disabled - Present when field is disabled
  • data-invalid - Present when field has errors

Form.FieldWithController

Field with built-in Controller for complex/controlled inputs.

Props

FieldPath<TFieldValues>
required
Field name matching the form schema
Control<TFieldValues, unknown, TTransformedValues>
Form control (auto-resolved from context if not provided)
function
required
Render function receiving field props
RegisterOptions
Validation rules
any
Default field value
boolean
Whether to unregister the field on unmount
boolean
Disable the field

Form.FieldBoundController

Controller that automatically uses the parent Field’s name from context.

Props

function
required
Render function receiving field props
RegisterOptions
Validation rules
any
Default field value
boolean
Whether to unregister on unmount
boolean
Disable the field

Form.FieldContext

Access field context values (name, IDs) via render props.

Props

function
Render function receiving field context
function
Alternative to children

Form.Label

Accessible label element automatically associated with the input.

Props

string
Custom ID for the associated input (auto-resolved from context if not provided)
string
CSS class names
React.ReactNode
Label content

Data Attributes

  • data-scope="form"
  • data-part="label"
  • data-slot="form-label"
  • data-disabled - Present when field is disabled
  • data-invalid - Present when field has errors

Form.Input

Input field with automatic registration and validation.

Props

React.HTMLInputTypeAttribute
default:"text"
Input type (text, email, password, etc.)
RegisterOptions
Validation rules
string
CSS class names
object
Class names for input parts
  • input?: string - Input element classes
  • inputGroup?: string - Input group wrapper classes (for password inputs)
  • eyeIcon?: string - Password toggle icon classes
  • error?: string - Error state classes
boolean | EyeIconObject
Password visibility toggle configuration (overrides Form.Root setting)

Data Attributes

  • data-scope="form"
  • data-part="input"
  • data-slot="form-input"
  • data-disabled - Present when disabled
  • data-invalid - Present when field has errors

Form.TextArea

Multi-line text input field.

Props

RegisterOptions
Validation rules
string
CSS class names
object
Class names for textarea parts
  • base?: string - Textarea element classes
  • error?: string - Error state classes

Data Attributes

  • data-scope="form"
  • data-part="textarea"
  • data-slot="form-textarea"
  • data-disabled - Present when disabled
  • data-invalid - Present when field has errors

Form.Select

Select dropdown input.

Props

RegisterOptions
Validation rules
string
CSS class names
object
Class names for select parts
  • base?: string - Select element classes
  • error?: string - Error state classes
React.ReactNode
Option elements

Data Attributes

  • data-scope="form"
  • data-part="select"
  • data-slot="form-select"
  • data-disabled - Present when disabled
  • data-invalid - Present when field has errors

Form.InputGroup

Container for input with left and/or right addons.

Props

string
CSS class names. Default includes flex items-center justify-between gap-2
React.ReactNode
required
Input element and left/right items

Data Attributes

  • data-scope="form"
  • data-part="input-group"
  • data-slot="form-input-group"
  • data-disabled - Present when field is disabled
  • data-invalid - Present when field has errors

Form.InputLeftItem

Left-side addon for InputGroup.

Props

React.ElementType
default:"span"
The element type to render as
string
CSS class names. Default includes inline-flex items-center justify-center
React.ReactNode
Addon content (icon, text, etc.)

Data Attributes

  • data-scope="form"
  • data-part="left-item"
  • data-slot="form-left-item"

Form.InputRightItem

Right-side addon for InputGroup.

Props

React.ElementType
default:"span"
The element type to render as
string
CSS class names. Default includes inline-flex items-center justify-center
React.ReactNode
Addon content (icon, text, etc.)

Data Attributes

  • data-scope="form"
  • data-part="right-item"
  • data-slot="form-right-item"

Form.Description

Helper text providing additional context for the field.

Props

string
CSS class names. Default includes text-[12px]
React.ReactNode
Description content

Form.ErrorMessage

Display validation error messages.

Props

FieldPath<TFieldValues> | string
Field name to show errors for (auto-resolved from context if not provided)
'regular' | 'root'
default:"regular"
Error type
  • regular - Field-specific errors
  • root - Form-level errors
string
CSS class names for error messages. Default includes text-[13px] text-zu-destructive

Data Attributes

  • data-scope="form"
  • data-part="error-message"
  • data-slot="form-error-message"
  • data-index - Message index for multiple errors

Form.ErrorMessagePrimitive

Low-level error message component with full customization.

Props

FieldPath<TFieldValues> | string
required
Field name to show errors for
'regular' | 'root'
default:"regular"
Error type
Control<TFieldValues>
Form control
function
required
Custom render function for each error
object
Class names for error parts
  • container?: string - Error list container
  • errorMessage?: string - Individual error message
  • errorMessageAnimation?: string - Shake animation class (default: animate-shake)
boolean
default:false
Disable shake animation on error
boolean
default:false
Disable auto-scroll to error field

Form.Submit

Form submit button.

Props

React.ElementType
default:"button"
The element type to render as
boolean
Merge props with immediate child element
'submit' | 'button' | 'reset'
default:"submit"
Button type
string
CSS class names
React.ReactNode
Button content

Data Attributes

  • data-scope="form"
  • data-part="submit"
  • data-slot="form-submit"

Form.Watch

Watch form values and render based on changes.

Props

FieldPath<TFieldValues> | FieldPath<TFieldValues>[]
Field name(s) to watch (auto-resolved from context if not provided)
Control<TFieldValues>
Form control
any
Default value when field is undefined
boolean
Disable watching
boolean
Enable exact match for field names
function
required
Render function receiving watched value(s)
function
Alternative to children

Form.StateSubscribe

Subscribe to form state changes (errors, isDirty, isSubmitting, etc.).

Props

FieldPath<TFieldValues> | FieldPath<TFieldValues>[]
Field name(s) to subscribe to
Control<TFieldValues>
Form control
boolean
Disable subscription
boolean
Enable exact match for field names
function
required
Render function receiving form state
function
Alternative to children

Types

FieldValues

FieldState

FieldContextValue

FormRootContext

Hooks

useFormMethodsContext

Access the form methods from React Hook Form.

useFormFieldContext

Access the current field context.

useFormRootContext

Access the form root context (from React Hook Form).