RefactKit enforces a strict form composition pattern built on two complementary libraries: TanStack Form for state management and validation, and Base UI primitives for the markup. This separation keeps business logic in one place and visual structure in another — and it ensures every form field is accessible by default through proper ARIA attributes and semantic HTML.Documentation Index
Fetch the complete documentation index at: https://docs.refactkit.com/llms.txt
Use this file to discover all available pages before exploring further.
The composition pattern
Every form in RefactKit uses the same stack of components:| Component | Role |
|---|---|
<FieldGroup> | Container that groups related fields with consistent spacing |
<Field> | Wrapper for a single field; receives data-invalid for styling |
<FieldLabel> | Accessible label linked to the input via htmlFor |
<Input> | The text input; receives aria-invalid for screen readers |
<FieldDescription> | Renders hint text or error messages below the input |
@/components/ui:
Complete working example
The pattern below is the canonical form implementation in RefactKit. Study the placement ofdata-invalid on <Field> and aria-invalid on <Input> — both must be set for full accessibility coverage:
Add validation
Pass avalidators object to form.Field to attach validation rules. TanStack Form calls onChange validators on every keystroke and onBlur validators when the field loses focus:
Form-level configuration
Configure default values, async validation, and submission handling on theuseForm call:
form.state.isSubmitting to disable the submit button during in-flight requests:
Multi-field forms
Wrap multiple fields in a single<FieldGroup>. Do not use <div> tags with arbitrary spacing utilities — <FieldGroup> provides the correct vertical rhythm automatically:
Validation state: data-invalid and aria-invalid
RefactKit uses two complementary attributes to communicate invalid state:
data-invalidon<Field>— drives CSS styling via Tailwind’sdata-[invalid=true]:variant. The field label, border, and background can all change color when this attribute is present.aria-invalidon<Input>— signals to screen readers and assistive technologies that the field contains an error.
Never use generic
<div> containers with arbitrary spacing classes like space-y-4 to structure form fields. Always use <FieldGroup> and <Field> — this enforces consistent visual rhythm across the app and ensures the Base UI styling system can apply its validation styles correctly.Available UI components
Beyond the form-specific primitives,@/components/ui exports a full set of Base UI components you can use inside forms:
Select,SelectContent,SelectItem,SelectTrigger,SelectValue— dropdown selectorsCheckbox— boolean togglesLabel— standalone label for non-TanStack-Form usageButton— submit and cancel actionsSpinner— inline loading indicator for async submissionsAvatar,AvatarImage,AvatarFallback— user/org image display

