Home / Function/ FormTanstackComplex() — ui Function Reference

FormTanstackComplex() — ui Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  7f20bfa4_7ad7_bf20_af8b_83edfbdc7fa2["FormTanstackComplex()"]
  e531e21d_390d_6e29_d379_d6d7e2e6e5ec["form-tanstack-complex.tsx"]
  7f20bfa4_7ad7_bf20_af8b_83edfbdc7fa2 -->|defined in| e531e21d_390d_6e29_d379_d6d7e2e6e5ec
  style 7f20bfa4_7ad7_bf20_af8b_83edfbdc7fa2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/v4/registry/new-york-v4/examples/form-tanstack-complex.tsx lines 82–313

export default function FormTanstackComplex() {
  const form = useForm({
    defaultValues: {
      plan: "basic",
      billingPeriod: "monthly",
      addons: [] as string[],
      emailNotifications: false,
    },
    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 max-w-sm">
      <CardContent>
        <form
          id="subscription-form"
          onSubmit={(e) => {
            e.preventDefault()
            form.handleSubmit()
          }}
        >
          <FieldGroup>
            <form.Field
              name="plan"
              children={(field) => {
                const isInvalid =
                  field.state.meta.isTouched && !field.state.meta.isValid
                return (
                  <FieldSet>
                    <FieldLegend>Subscription Plan</FieldLegend>
                    <FieldDescription>
                      Choose your subscription plan.
                    </FieldDescription>
                    <RadioGroup
                      name={field.name}
                      value={field.state.value}
                      onValueChange={field.handleChange}
                    >
                      <FieldLabel htmlFor="basic">
                        <Field
                          orientation="horizontal"
                          data-invalid={isInvalid}
                        >
                          <FieldContent>
                            <FieldTitle>Basic</FieldTitle>
                            <FieldDescription>
                              For individuals and small teams
                            </FieldDescription>
                          </FieldContent>
                          <RadioGroupItem
                            value="basic"
                            id="basic"
                            aria-invalid={isInvalid}
                          />
                        </Field>
                      </FieldLabel>
                      <FieldLabel htmlFor="pro">
                        <Field
                          orientation="horizontal"
                          data-invalid={isInvalid}
                        >
                          <FieldContent>
                            <FieldTitle>Pro</FieldTitle>

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free