Home / Function/ FormTanstackCheckbox() — ui Function Reference

FormTanstackCheckbox() — ui Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  7426e3a8_f71a_fe48_d1f7_921be03f033c["FormTanstackCheckbox()"]
  f7e15869_ccfe_4157_f9ae_321a69a23f51["form-tanstack-checkbox.tsx"]
  7426e3a8_f71a_fe48_d1f7_921be03f033c -->|defined in| f7e15869_ccfe_4157_f9ae_321a69a23f51
  style 7426e3a8_f71a_fe48_d1f7_921be03f033c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/v4/registry/new-york-v4/examples/form-tanstack-checkbox.tsx lines 53–200

export default function FormTanstackCheckbox() {
  const form = useForm({
    defaultValues: {
      responses: true,
      tasks: [] as string[],
    },
    validators: {
      onSubmit: formSchema,
    },
    onSubmit: async ({ value }) => {
      toast("You submitted the following values:", {
        description: (
          <pre className="bg-code text-code-foreground mt-2 w-[320px] overflow-x-auto rounded-md p-4">
            <code>{JSON.stringify(value, null, 2)}</code>
          </pre>
        ),
        position: "bottom-right",
        classNames: {
          content: "flex flex-col gap-2",
        },
        style: {
          "--border-radius": "calc(var(--radius)  + 4px)",
        } as React.CSSProperties,
      })
    },
  })

  return (
    <Card className="w-full sm:max-w-md">
      <CardHeader>
        <CardTitle>Notifications</CardTitle>
        <CardDescription>Manage your notification preferences.</CardDescription>
      </CardHeader>
      <CardContent>
        <form
          id="form-tanstack-checkbox"
          onSubmit={(e) => {
            e.preventDefault()
            form.handleSubmit()
          }}
        >
          <FieldGroup>
            <form.Field
              name="responses"
              children={(field) => {
                const isInvalid =
                  field.state.meta.isTouched && !field.state.meta.isValid
                return (
                  <FieldSet>
                    <FieldLegend variant="label">Responses</FieldLegend>
                    <FieldDescription>
                      Get notified for requests that take time, like research or
                      image generation.
                    </FieldDescription>
                    <FieldGroup data-slot="checkbox-group">
                      <Field orientation="horizontal" data-invalid={isInvalid}>
                        <Checkbox
                          id="form-tanstack-checkbox-responses"
                          name={field.name}
                          checked={field.state.value}
                          onCheckedChange={(checked) =>
                            field.handleChange(checked === true)
                          }
                          disabled
                        />
                        <FieldLabel
                          htmlFor="form-tanstack-checkbox-responses"
                          className="font-normal"
                        >
                          Push notifications
                        </FieldLabel>
                      </Field>
                    </FieldGroup>
                    {isInvalid && (
                      <FieldError errors={field.state.meta.errors} />
                    )}
                  </FieldSet>
                )
              }}
            />
            <FieldSeparator />

Subdomains

Frequently Asked Questions

What does FormTanstackCheckbox() do?
FormTanstackCheckbox() is a function in the ui codebase, defined in apps/v4/registry/new-york-v4/examples/form-tanstack-checkbox.tsx.
Where is FormTanstackCheckbox() defined?
FormTanstackCheckbox() is defined in apps/v4/registry/new-york-v4/examples/form-tanstack-checkbox.tsx at line 53.

Analyze Your Own Codebase

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

Try Supermodel Free