{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "field",
  "title": "Field",
  "description": "Field layout with label and help.",
  "registryDependencies": [
    "label",
    "separator"
  ],
  "files": [
    {
      "path": "registry/new-york/ui/field.tsx",
      "content": "\"use client\";\n\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport * as React from \"react\";\nimport { cn } from \"@/lib/utils\";\nimport { Label } from \"@/registry/new-york/ui/label\";\nimport { Separator } from \"@/registry/new-york/ui/separator\";\n\nconst FieldSet = React.forwardRef<\n  HTMLFieldSetElement,\n  React.ComponentProps<\"fieldset\">\n>(function FieldSet({ className, ...props }, ref) {\n  return (\n    <fieldset\n      aria-disabled={(props as any).disabled ? true : undefined}\n      className={cn(\n        \"flex touch-manipulation flex-col gap-6\",\n        \"has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3\",\n        className\n      )}\n      data-slot=\"field-set\"\n      ref={ref}\n      {...props}\n    />\n  );\n});\n\nconst FieldLegend = React.forwardRef<\n  HTMLLegendElement,\n  React.ComponentProps<\"legend\"> & { variant?: \"legend\" | \"label\" }\n>(function FieldLegend({ className, variant = \"legend\", ...props }, ref) {\n  return (\n    <legend\n      className={cn(\n        \"mb-3 font-medium\",\n        \"data-[variant=legend]:text-base\",\n        \"data-[variant=label]:text-sm\",\n        className\n      )}\n      data-slot=\"field-legend\"\n      data-variant={variant}\n      ref={ref}\n      {...props}\n    />\n  );\n});\n\nconst FieldGroup = React.forwardRef<\n  HTMLDivElement,\n  React.ComponentProps<\"div\">\n>(function FieldGroup({ className, ...props }, ref) {\n  return (\n    <div\n      className={cn(\n        \"group/field-group @container/field-group flex w-full touch-manipulation flex-col gap-7 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4\",\n        className\n      )}\n      data-slot=\"field-group\"\n      ref={ref}\n      {...props}\n    />\n  );\n});\n\nconst fieldVariants = cva(\n  \"group/field flex w-full gap-2 data-[invalid=true]:text-destructive\",\n  {\n    variants: {\n      orientation: {\n        vertical: [\"flex-col [&>*]:w-full [&>.sr-only]:w-auto\"],\n        horizontal: [\n          \"flex-row items-center\",\n          \"[&>[data-slot=field-label]]:flex-auto\",\n          \"has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px\",\n        ],\n        responsive: [\n          \"@md/field-group:flex-row flex-col @md/field-group:items-center @md/field-group:[&>*]:w-auto [&>*]:w-full [&>.sr-only]:w-auto\",\n          \"@md/field-group:[&>[data-slot=field-label]]:flex-auto\",\n          \"@md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px\",\n        ],\n      },\n    },\n    defaultVariants: {\n      orientation: \"vertical\",\n    },\n  }\n);\n\nconst Field = React.forwardRef<\n  HTMLDivElement,\n  React.ComponentProps<\"div\"> & VariantProps<typeof fieldVariants>\n>(function Field({ className, orientation = \"vertical\", ...props }, ref) {\n  return (\n    <div\n      aria-disabled={(props as any)[\"data-disabled\"] ? true : undefined}\n      className={cn(fieldVariants({ orientation }), className)}\n      data-orientation={orientation}\n      data-slot=\"field\"\n      ref={ref}\n      role=\"group\"\n      {...props}\n    />\n  );\n});\n\nconst FieldContent = React.forwardRef<\n  HTMLDivElement,\n  React.ComponentProps<\"div\">\n>(function FieldContent({ className, ...props }, ref) {\n  return (\n    <div\n      className={cn(\n        \"group/field-content flex flex-1 flex-col gap-2 leading-snug\",\n        className\n      )}\n      data-slot=\"field-content\"\n      ref={ref}\n      {...props}\n    />\n  );\n});\n\nfunction FieldLabel({\n  className,\n  ...props\n}: React.ComponentProps<typeof Label>) {\n  return (\n    <Label\n      className={cn(\n        \"group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50\",\n        \"has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border *:data-[slot=field]:p-4\",\n        \"has-data-[state=checked]:border-primary has-data-[state=checked]:bg-primary/5 dark:has-data-[state=checked]:bg-primary/10\",\n        className\n      )}\n      data-slot=\"field-label\"\n      {...props}\n    />\n  );\n}\n\nconst FieldTitle = React.forwardRef<\n  HTMLDivElement,\n  React.ComponentProps<\"div\">\n>(function FieldTitle({ className, ...props }, ref) {\n  return (\n    <div\n      className={cn(\n        \"flex w-fit items-center gap-2 font-medium text-sm leading-snug group-data-[disabled=true]/field:opacity-50\",\n        className\n      )}\n      data-slot=\"field-title\"\n      ref={ref}\n      {...props}\n    />\n  );\n});\n\nconst FieldDescription = React.forwardRef<\n  HTMLParagraphElement,\n  React.ComponentProps<\"p\">\n>(function FieldDescription({ className, ...props }, ref) {\n  return (\n    <p\n      className={cn(\n        \"font-normal text-muted-foreground text-sm tabular-nums leading-normal group-has-data-[orientation=horizontal]/field:text-balance\",\n        \"nth-last-2:-mt-1 last:mt-0 [[data-variant=legend]+&]:-mt-1.5\",\n        \"[&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4\",\n        className\n      )}\n      data-slot=\"field-description\"\n      ref={ref}\n      {...props}\n    />\n  );\n});\n\nconst FieldSeparator = React.forwardRef<\n  HTMLDivElement,\n  React.ComponentProps<\"div\"> & { children?: React.ReactNode }\n>(function FieldSeparator({ children, className, ...props }, ref) {\n  return (\n    <div\n      className={cn(\n        \"relative -my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2\",\n        className\n      )}\n      data-content={!!children}\n      data-slot=\"field-separator\"\n      ref={ref}\n      {...props}\n    >\n      <Separator className=\"absolute inset-0 top-1/2\" />\n      {children && (\n        <span\n          className=\"relative mx-auto block w-fit bg-background px-2 text-muted-foreground\"\n          data-slot=\"field-separator-content\"\n        >\n          {children}\n        </span>\n      )}\n    </div>\n  );\n});\n\nfunction FieldError({\n  className,\n  children,\n  errors,\n  ...props\n}: React.ComponentProps<\"div\"> & {\n  errors?: Array<{ message?: string } | undefined>;\n}) {\n  const content = React.useMemo(() => {\n    if (children) {\n      return children;\n    }\n\n    if (!errors?.length) {\n      return null;\n    }\n\n    const uniqueErrors = [\n      ...new Map(errors.map((error) => [error?.message, error])).values(),\n    ];\n\n    if (uniqueErrors?.length == 1) {\n      return uniqueErrors[0]?.message;\n    }\n\n    return (\n      <ul className=\"ml-4 flex list-disc flex-col gap-1\">\n        {uniqueErrors.map(\n          (error, index) =>\n            error?.message && <li key={index}>{error.message}</li>\n        )}\n      </ul>\n    );\n  }, [children, errors]);\n\n  if (!content) {\n    return null;\n  }\n\n  return (\n    <div\n      aria-atomic=\"true\"\n      aria-live=\"polite\"\n      className={cn(\"font-normal text-destructive text-sm\", className)}\n      data-slot=\"field-error\"\n      {...props}\n    >\n      {content}\n    </div>\n  );\n}\n\nexport {\n  Field,\n  FieldLabel,\n  FieldDescription,\n  FieldError,\n  FieldGroup,\n  FieldLegend,\n  FieldSeparator,\n  FieldSet,\n  FieldContent,\n  FieldTitle,\n};\n",
      "type": "registry:ui"
    }
  ],
  "docs": "https://ui.shadcn.com/docs/components/field?utm_source=hextaui&utm_medium=referral&utm_campaign=component-docs&ref=hextaui.com",
  "categories": [
    "component"
  ],
  "type": "registry:ui"
}