All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- Small issue related to
<Field>css className: The field was adding a Tailwind class to the field making the layout broken on some components such as Radio Groups.
<RadioGroup>usage example: The<RadioGroup>component is composed by many<Field>components. In this case the<FieldDescription>is placed outside a<Field>, where a context does not exist. We added some example on how to use it correctly.
- General Availability of the new Form component set: The Form component suite is now stable and production-ready.
- Component naming alignment with shadcn Field components: Internal component names have been aligned with shadcn Field components and are exported as overrides when imported from this library:
Field,FieldLabel,FieldControl,FieldDescription,FieldError.
- Hierarchy support in form-hook: The form hook now registers the new Form components in its hierarchy, enabling two usage modes in the same file:
- Regular usage with the Form components.
- Optional hierarchical usage where the render-prop
fieldexposesfield.Field,field.Label,field.Control,field.Description,field.Erroralongside shadcn Field components.
- Tests for hierarchical usage: Added
test/components/ui/form_hierarchy.test.tsxto validate behavior, ARIA attributes, and error handling when using the field hierarchy.
- Form component overrides: Importing components from
@/components/ui/formnow provides components that override shadcn Field components with improved accessibility and error state handling.
- Renamed internal components to match shadcn Field naming. Replace previous names with the following:
FormItem→FieldFormLabel→FieldLabelFormControl→FieldControlFormDescription→FieldDescriptionFormMessage→FieldError
- Import paths unchanged for the new set; ensure you import from
@/components/ui/formand@/hooks/form-hook.
- Update JSX usages to the new component names listed above.
- Keep importing Form components from
@/components/ui/formand the hook from@/hooks/form-hook. - Optional: Adopt the hierarchical usage pattern where the
fieldrender prop providesfield.Field,field.Label,field.Control,field.Description, andfield.Errorfor local scoping alongside shadcn Field components.
- New shadcn/ui Field Components: Complete rewrite using modern shadcn/ui field components
Fieldcomponent with orientation variants (vertical, horizontal, responsive)FieldLabelcomponent with enhanced styling and accessibilityFieldDescriptioncomponent with improved typographyFieldErrorcomponent with better error handling and displayFieldGroup,FieldLegend,FieldSeparator,FieldSet,FieldContent,FieldTitlecomponents
- Enhanced Accessibility: Improved ARIA attributes and semantic HTML structure
- Responsive Design: Added responsive orientation support for form fields
- Better Error Handling: Enhanced error display with support for multiple errors and custom error content
- FormItem Component: Now uses the new
Fieldcomponent instead of basicdiv- Added
data-invalidattribute for better styling control - Improved error state management
- Added
- FormLabel Component: Now uses
FieldLabelinstead of basicLabel- Enhanced styling with error state indicators
- Better integration with form validation
- FormDescription Component: Now uses
FieldDescriptionwith improved typography - FormMessage Component: Now uses
FieldErrorwith enhanced error display - FormControl Component: Improved
aria-describedbyattribute handling- Changed from string concatenation to array filtering for better null handling
- Better filtering of empty description IDs
- More robust accessibility support
- Component Architecture: Migrated from basic HTML elements to specialized field components
- Styling System: Enhanced with class-variance-authority for better variant management
- Type Safety: Improved TypeScript integration with better prop types
- Performance: Optimized re-renders with better memoization strategies
- Import Paths: Form components now import from
@/components/ui/fieldinstead of using basic HTML elements - Component Props: Component prop inheritance has changed significantly:
FormItem: Now inherits fromReact.ComponentProps<typeof Field>instead ofReact.ComponentProps<"div">FormLabel: Now inherits fromReact.ComponentProps<typeof FieldLabel>instead ofReact.ComponentProps<typeof LabelPrimitive.Root>FormDescription: Now inherits fromReact.ComponentProps<typeof FieldDescription>instead ofReact.ComponentProps<"p">FormMessage: Now inherits fromReact.ComponentProps<typeof FieldError>instead ofReact.ComponentProps<"p">
- Prop Types: Components now inherit additional props from their respective field components (orientation variants, error handling, etc.)
- Styling Classes: Updated CSS classes to use the new field component styling system
To migrate from v0.0.0 to v0.5.0-beta:
- Install Required Dependencies: Install the new shadcn field component:
pnpm dlx shadcn@latest add field
- Update Imports: Change imports from
old_form.tsxtoform.tsx - Update Hook Imports: Change imports from
old-form-hook.tsxtoform-hook.tsx - Review Styling: Check if any custom CSS needs updates due to new class names
- Test Accessibility: Verify that accessibility features work as expected with the new components
- Basic form components using TanStack Form
- Form validation and error handling
- Basic accessibility support
- Simple form item, label, control, description, and message components