Home / Function/ CheckboxReactHookFormMultiple() — ui Function Reference

CheckboxReactHookFormMultiple() — ui Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  e0132e0c_1569_b9b0_dcd6_7fbee2c5dcac["CheckboxReactHookFormMultiple()"]
  506fed82_d4ef_c663_21e0_dbe8a6bda927["checkbox-form-multiple.tsx"]
  e0132e0c_1569_b9b0_dcd6_7fbee2c5dcac -->|defined in| 506fed82_d4ef_c663_21e0_dbe8a6bda927
  style e0132e0c_1569_b9b0_dcd6_7fbee2c5dcac fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

deprecated/www/registry/default/examples/checkbox-form-multiple.tsx lines 53–127

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({
      title: "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 {...form}>
      <form onSubmit={form.handleSubmit(onSubmit)} className="space-y-8">
        <FormField
          control={form.control}
          name="items"
          render={() => (
            <FormItem>
              <div className="mb-4">
                <FormLabel className="text-base">Sidebar</FormLabel>
                <FormDescription>
                  Select the items you want to display in the sidebar.
                </FormDescription>
              </div>
              {items.map((item) => (
                <FormField
                  key={item.id}
                  control={form.control}
                  name="items"
                  render={({ field }) => {
                    return (
                      <FormItem
                        key={item.id}
                        className="flex flex-row items-start space-x-3 space-y-0"
                      >
                        <FormControl>
                          <Checkbox
                            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>
                        <FormLabel className="font-normal">
                          {item.label}
                        </FormLabel>
                      </FormItem>
                    )
                  }}
                />
              ))}
              <FormMessage />
            </FormItem>
          )}
        />
        <Button type="submit">Submit</Button>
      </form>
    </Form>
  )
}

Subdomains

Frequently Asked Questions

What does CheckboxReactHookFormMultiple() do?
CheckboxReactHookFormMultiple() is a function in the ui codebase, defined in deprecated/www/registry/default/examples/checkbox-form-multiple.tsx.
Where is CheckboxReactHookFormMultiple() defined?
CheckboxReactHookFormMultiple() is defined in deprecated/www/registry/default/examples/checkbox-form-multiple.tsx at line 53.

Analyze Your Own Codebase

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

Try Supermodel Free