Switch
Simple on/off setting switch.
Preview
Receive emails about new products, features, and more.
Usage
<FormFieldcontrol={form.control}name="receive_marketing_emails"render={({ field }) => (<FormItem className="flex flex-row items-center gap-3"><FormControl><SwitchclassName="mb-0"checked={field.value === true}onCheckedChange={(nextValue) => {field.onChange(nextValue)form.setValue(field.name, nextValue, {shouldValidate: true,shouldDirty: true,shouldTouch: true})}}/></FormControl><div className="space-y-0.5 text-left"><FormLabel>Receive Marketing Emails</FormLabel><FormDescription>Receive emails about new products, features, and more.</FormDescription></div><FormMessage /></FormItem>)}/>
Details
Copy this field block into a React Hook Form setup and swap the demo content for your own schema and labels.
form-builder/components/ui/switch.tsx