Home / Function/ CheckboxReactHookFormMultiple() — supabase Function Reference

CheckboxReactHookFormMultiple() — supabase Function Reference

Architecture documentation for the CheckboxReactHookFormMultiple() function in checkbox-form-multiple.tsx from the supabase codebase.

Entity Profile

Relationship Graph

Source Code

apps/design-system/registry/default/example/checkbox-form-multiple.tsx lines 52–119

export default function CheckboxReactHookFormMultiple() {
  const form = useForm<z.infer<typeof FormSchema>>({
    resolver: zodResolver(FormSchema),
    defaultValues: {
      items: ['recents', 'home'],
    },
  })

  function onSubmit(data: z.infer<typeof FormSchema>) {
    toast('You submitted the following values:', {
      description: (
        <pre className="mt-2 w-[340px] rounded-md bg-slate-950 p-4">
          <code className="text-white">{JSON.stringify(data, null, 2)}</code>
        </pre>
      ),
    })
  }

  return (
    <Form_Shadcn_ {...form}>
      <form onSubmit={form.handleSubmit(onSubmit)} className="space-y-8">
        <FormField_Shadcn_
          control={form.control}
          name="items"
          render={() => (
            <FormItem_Shadcn_>
              <div className="mb-4">
                <FormLabel_Shadcn_ className="text-base">Sidebar</FormLabel_Shadcn_>
                <FormDescription_Shadcn_>
                  Select the items you want to display in the sidebar.
                </FormDescription_Shadcn_>
              </div>
              {items.map((item) => (
                <FormField_Shadcn_
                  key={item.id}
                  control={form.control}
                  name="items"
                  render={({ field }) => {
                    return (
                      <FormItem_Shadcn_
                        key={item.id}
                        className="flex flex-row items-start space-x-3 space-y-0"
                      >
                        <FormControl_Shadcn_>
                          <Checkbox_Shadcn_
                            checked={field.value?.includes(item.id)}
                            onCheckedChange={(checked) => {
                              return checked
                                ? field.onChange([...field.value, item.id])
                                : field.onChange(field.value?.filter((value) => value !== item.id))
                            }}
                          />
                        </FormControl_Shadcn_>
                        <FormLabel_Shadcn_ className="font-normal">{item.label}</FormLabel_Shadcn_>
                      </FormItem_Shadcn_>
                    )
                  }}
                />
              ))}
              <FormMessage_Shadcn_ />
            </FormItem_Shadcn_>
          )}
        />
        <Button htmlType="submit">Submit</Button>
      </form>
    </Form_Shadcn_>
  )
}

Domain

Subdomains

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free