Atoms
Form
React Hook Form integration with validation and error handling.
shadcn/uiBased on shadcn/ui with Formance brand styling.
Installation#
npx shadcn@latest add @formance/formInstall the following dependencies:
npm install react-hook-form radix-uiCopy and paste the following code into your project.
Update the import paths to match your project setup.
Usage#
import {
Form,
FormControl,
FormDescription,
FormField,
FormItem,
FormLabel,
FormMessage,
} from '@/components/ui/form'<Form {...form}>
<form onSubmit={form.handleSubmit(onSubmit)}>
<FormField
control={form.control}
name="email"
render={({ field }) => (
<FormItem>
<FormLabel>Email</FormLabel>
<FormControl>
<Input placeholder="you@formance.com" {...field} />
</FormControl>
<FormDescription>Your account email address.</FormDescription>
<FormMessage />
</FormItem>
)}
/>
</form>
</Form>