Skip to main content

Overview

Enter a valid email address
Select a role
Choose the user’s permission level.
The Form component provides composable wrappers — FormField, FormItem, FormLabel, FormDescription, FormMessage — that connect to React Hook Form and uniformly apply A’raf DS token-based styling to labels, helper text, and error messages.
Form is a thin integration layer, not a standalone form UI. It requires react-hook-form as a peer dependency and pairs with any A’raf DS input component (Input, Select, Checkbox, etc.).

Installation


Usage


Variants

Basic Form Field

A single field with label and validation message.

With Helper Text

Use FormDescription to add supporting guidance below the input.
Must be at least 8 characters and include a number.

With Validation Error

FormMessage automatically renders the Zod/RHF error message in the error state.
Enter a valid email address

Complete Form Example

Profile settings
Write a short introduction about yourself.

API Reference

Form

UseFormReturn
required
The React Hook Form instance returned by useForm(). Passed to the internal FormProvider.
(data: T) => void
required
Submit handler. Typically form.handleSubmit(handler).
string
Additional class names for the <form> element.

FormField

Control
required
The control object from useForm().
string
required
Field name matching the schema key.
({ field, fieldState }) => ReactNode
required
Render function receiving registered field props and validation state.

FormItem

Container for a single field — adds consistent vertical spacing between label, control, description, and message.

FormLabel

boolean
default:"false"
Appends a red asterisk (*) to indicate required fields.

FormDescription

Renders helper text below the input in #667085 muted color.

FormMessage

Automatically reads and displays the validation error for the current field from fieldState.error. Renders nothing when there is no error.

FormControl

Binds the ARIA attributes (aria-invalid, aria-describedby) between the input and FormMessage. Always wrap your input component with FormControl.

Accessibility

  • FormLabel renders a <label> element with a for attribute automatically linked to the input via FormControl
  • FormMessage uses role="alert" so screen readers announce validation errors immediately on submit
  • FormControl sets aria-invalid="true" on the input when a field error exists
  • FormDescription is linked to the input via aria-describedby for assistive technology
  • Required fields should be marked with both the required prop on FormLabel and the Zod .min(1) validation rule

Do’s & Don’ts

Do

  • Always wrap inputs with FormControl to get correct ARIA bindings
  • Use FormDescription for guidance the user needs before they fill the field
  • Use FormMessage for validation errors triggered after interaction
  • Keep labels short and descriptive — “Email address” not “Please enter your email”

Don't

  • Don’t use FormDescription for error messages — use FormMessage instead
  • Don’t skip FormLabel — placeholder text alone is not accessible
  • Don’t place FormMessage above the input — errors should appear below
  • Don’t use form.handleSubmit outside the onSubmit prop — let Form manage it