Home / File/ radio-group-form.tsx — ui Source File

radio-group-form.tsx — ui Source File

Architecture documentation for radio-group-form.tsx, a tsx file in the ui codebase. 7 imports, 0 dependents.

File tsx ComponentRegistry ChartRegistry 7 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  faee607a_76c9_1c60_34db_54133bc103fe["radio-group-form.tsx"]
  3d40a3bf_c062_4304_329a_00b1b72e8523["zod"]
  faee607a_76c9_1c60_34db_54133bc103fe --> 3d40a3bf_c062_4304_329a_00b1b72e8523
  6d65354d_8f59_2cfc_4783_24b2eb870bc4["react-hook-form"]
  faee607a_76c9_1c60_34db_54133bc103fe --> 6d65354d_8f59_2cfc_4783_24b2eb870bc4
  6802ce19_522d_e5fb_e458_8826d9f6952e["zod"]
  faee607a_76c9_1c60_34db_54133bc103fe --> 6802ce19_522d_e5fb_e458_8826d9f6952e
  64d95022_f8e1_3e94_bb97_22b3ebca757e["use-toast"]
  faee607a_76c9_1c60_34db_54133bc103fe --> 64d95022_f8e1_3e94_bb97_22b3ebca757e
  aa2f3ec6_f291_3763_88ec_65a3f5ad5939["button"]
  faee607a_76c9_1c60_34db_54133bc103fe --> aa2f3ec6_f291_3763_88ec_65a3f5ad5939
  7a6b0be4_eca5_4970_1a93_79d670ef529e["form"]
  faee607a_76c9_1c60_34db_54133bc103fe --> 7a6b0be4_eca5_4970_1a93_79d670ef529e
  e3816a69_e9ee_ea7d_ed26_21225e55c2ff["radio-group"]
  faee607a_76c9_1c60_34db_54133bc103fe --> e3816a69_e9ee_ea7d_ed26_21225e55c2ff
  style faee607a_76c9_1c60_34db_54133bc103fe fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"use client"

import { zodResolver } from "@hookform/resolvers/zod"
import { useForm } from "react-hook-form"
import { z } from "zod"

import { toast } from "@/registry/new-york/hooks/use-toast"
import { Button } from "@/registry/new-york/ui/button"
import {
  Form,
  FormControl,
  FormField,
  FormItem,
  FormLabel,
  FormMessage,
} from "@/registry/new-york/ui/form"
import { RadioGroup, RadioGroupItem } from "@/registry/new-york/ui/radio-group"

const FormSchema = z.object({
  type: z.enum(["all", "mentions", "none"], {
    required_error: "You need to select a notification type.",
  }),
})

export default function RadioGroupForm() {
  const form = useForm<z.infer<typeof FormSchema>>({
    resolver: zodResolver(FormSchema),
  })

  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="w-2/3 space-y-6">
        <FormField
          control={form.control}
          name="type"
          render={({ field }) => (
            <FormItem className="space-y-3">
              <FormLabel>Notify me about...</FormLabel>
              <FormControl>
                <RadioGroup
                  onValueChange={field.onChange}
                  defaultValue={field.value}
                  className="flex flex-col space-y-1"
                >
                  <FormItem className="flex items-center space-x-3 space-y-0">
                    <FormControl>
                      <RadioGroupItem value="all" />
                    </FormControl>
                    <FormLabel className="font-normal">
                      All new messages
                    </FormLabel>
                  </FormItem>
                  <FormItem className="flex items-center space-x-3 space-y-0">
                    <FormControl>
                      <RadioGroupItem value="mentions" />
                    </FormControl>
                    <FormLabel className="font-normal">
                      Direct messages and mentions
                    </FormLabel>
                  </FormItem>
                  <FormItem className="flex items-center space-x-3 space-y-0">
                    <FormControl>
                      <RadioGroupItem value="none" />
                    </FormControl>
                    <FormLabel className="font-normal">Nothing</FormLabel>
                  </FormItem>
                </RadioGroup>
              </FormControl>
              <FormMessage />
            </FormItem>
          )}
        />
        <Button type="submit">Submit</Button>
      </form>
    </Form>
  )
}

Subdomains

Functions

Dependencies

  • button
  • form
  • radio-group
  • react-hook-form
  • use-toast
  • zod
  • zod

Frequently Asked Questions

What does radio-group-form.tsx do?
radio-group-form.tsx is a source file in the ui codebase, written in tsx. It belongs to the ComponentRegistry domain, ChartRegistry subdomain.
What functions are defined in radio-group-form.tsx?
radio-group-form.tsx defines 1 function(s): RadioGroupForm.
What does radio-group-form.tsx depend on?
radio-group-form.tsx imports 7 module(s): button, form, radio-group, react-hook-form, use-toast, zod, zod.
Where is radio-group-form.tsx in the architecture?
radio-group-form.tsx is located at deprecated/www/registry/new-york/examples/radio-group-form.tsx (domain: ComponentRegistry, subdomain: ChartRegistry, directory: deprecated/www/registry/new-york/examples).

Analyze Your Own Codebase

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

Try Supermodel Free