Home / Function/ FormTanstackSelect() — ui Function Reference

FormTanstackSelect() — ui Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  a0d98531_ca2a_7760_91d7_03cffbb28000["FormTanstackSelect()"]
  904ca795_89fa_16d2_0a44_562c2dae0279["form-tanstack-select.tsx"]
  a0d98531_ca2a_7760_91d7_03cffbb28000 -->|defined in| 904ca795_89fa_16d2_0a44_562c2dae0279
  style a0d98531_ca2a_7760_91d7_03cffbb28000 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/v4/registry/new-york-v4/examples/form-tanstack-select.tsx lines 54–159

export default function FormTanstackSelect() {
  const form = useForm({
    defaultValues: {
      language: "",
    },
    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-lg">
      <CardHeader>
        <CardTitle>Language Preferences</CardTitle>
        <CardDescription>
          Select your preferred spoken language.
        </CardDescription>
      </CardHeader>
      <CardContent>
        <form
          id="form-tanstack-select"
          onSubmit={(e) => {
            e.preventDefault()
            form.handleSubmit()
          }}
        >
          <FieldGroup>
            <form.Field
              name="language"
              children={(field) => {
                const isInvalid =
                  field.state.meta.isTouched && !field.state.meta.isValid
                return (
                  <Field orientation="responsive" data-invalid={isInvalid}>
                    <FieldContent>
                      <FieldLabel htmlFor="form-tanstack-select-language">
                        Spoken Language
                      </FieldLabel>
                      <FieldDescription>
                        For best results, select the language you speak.
                      </FieldDescription>
                      {isInvalid && (
                        <FieldError errors={field.state.meta.errors} />
                      )}
                    </FieldContent>
                    <Select
                      name={field.name}
                      value={field.state.value}
                      onValueChange={field.handleChange}
                    >
                      <SelectTrigger
                        id="form-tanstack-select-language"
                        aria-invalid={isInvalid}
                        className="min-w-[120px]"
                      >
                        <SelectValue placeholder="Select" />
                      </SelectTrigger>
                      <SelectContent position="item-aligned">
                        <SelectItem value="auto">Auto</SelectItem>
                        <SelectSeparator />
                        {spokenLanguages.map((language) => (
                          <SelectItem
                            key={language.value}
                            value={language.value}
                          >

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free