{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"shadcn-studio/form-03","type":"registry:component","title":"Form 3","description":"Form with switch toggle controls for settings and preferences","dependencies":["@hookform/resolvers","lucide-react","react-hook-form","sonner","zod@3.25.76"],"registryDependencies":["alert","button","field","switch"],"files":[{"path":"src/registry/new-york/components/form/form-03.tsx","content":"'use client'\n\nimport * as React from 'react'\n\nimport { CheckCheckIcon } from 'lucide-react'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport { Controller, useForm } from 'react-hook-form'\nimport { toast } from 'sonner'\nimport * as z from 'zod'\n\nimport { Alert, AlertTitle } from '@/registry/new-york/ui/alert'\nimport { Button } from '@/registry/new-york/ui/button'\nimport { Field, FieldDescription, FieldError, FieldLabel } from '@/registry/new-york/ui/field'\nimport { Switch } from '@/registry/new-york/ui/switch'\n\n// Define the form schema\nconst formSchema = z.object({\n  stepTracker: z.boolean().refine(val => val === true, {\n    message: 'You must enable step tracker to proceed.'\n  })\n})\n\ntype FormValues = z.infer<typeof formSchema>\n\nconst SwitchFormDemo = () => {\n  const form = useForm<FormValues>({\n    resolver: zodResolver(formSchema),\n    defaultValues: {\n      stepTracker: false\n    }\n  })\n\n  function onSubmit(data: FormValues) {\n    toast.custom(() => (\n      <Alert className='border-green-600 text-green-600 dark:border-green-400 dark:text-green-400'>\n        <CheckCheckIcon />\n        <AlertTitle>Step tracker is {data.stepTracker ? 'enabled' : 'disabled'} &quot;Go! Run&quot;.</AlertTitle>\n      </Alert>\n    ))\n  }\n\n  return (\n    <form onSubmit={form.handleSubmit(onSubmit)} className='w-full max-w-xs space-y-6'>\n      <Controller\n        name='stepTracker'\n        control={form.control}\n        render={({ field, fieldState }) => (\n          <Field orientation='horizontal' data-invalid={fieldState.invalid} className='flex-col items-start!'>\n            <div className='flex gap-2'>\n              <Switch\n                id='stepTracker'\n                name={field.name}\n                checked={field.value}\n                onCheckedChange={field.onChange}\n                aria-invalid={fieldState.invalid}\n              />\n              <FieldLabel htmlFor='stepTracker'>Enable Daily Step Tracker</FieldLabel>\n            </div>\n            <div className='flex flex-col gap-2'>\n              <FieldDescription>Track your daily steps to help you reach your fitness goals.</FieldDescription>\n              {fieldState.invalid && <FieldError errors={[fieldState.error]} />}\n            </div>\n          </Field>\n        )}\n      />\n\n      <Button type='submit'>Activate</Button>\n    </form>\n  )\n}\n\nexport default SwitchFormDemo\n","type":"registry:component","target":"components/shadcn-studio/form/form-03.tsx"}]}