{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "field", "title": "Field", "description": "Form field layout primitives — set, group, label, description, error, and separator slots.", "dependencies": [ "@base-ui/react", "class-variance-authority", "clsx", "tailwind-merge" ], "registryDependencies": [ "https://ui.digital.nsw.gov.au/registry/r/theme.json", "https://ui.digital.nsw.gov.au/registry/r/label.json", "https://ui.digital.nsw.gov.au/registry/r/separator.json" ], "files": [ { "path": "src/components/field.tsx", "content": "'use client'\n\nimport { Field as FieldPrimitive } from '@base-ui/react/field'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport * as React from 'react'\n\nimport { Label } from '@/components/label'\nimport { Separator } from '@/components/separator'\nimport { cn } from '@/lib/utils'\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Base UI Field\n// ─────────────────────────────────────────────────────────────────────────────\n//\n// `Field`, `FieldLabel`, `FieldDescription`, and `FieldError` wrap Base UI's\n// Field primitive (@base-ui/react/field). Base UI owns the accessible wiring:\n// the label is associated with the control, and any description/error ids are\n// added to the control's `aria-describedby` automatically — no manual\n// `htmlFor` / `aria-describedby` / `aria-invalid` plumbing required. Set\n// `invalid` on `Field` (e.g. from react-hook-form) and the control receives\n// `aria-invalid` and the wrapper gets `data-invalid` for free.\n//\n// Base UI's Field parts must live inside a `Field.Root`. To keep the previous\n// behaviour where a label/description/error could also be used standalone\n// (e.g. a group-level FieldDescription directly inside a FieldSet), FieldLabel/\n// FieldDescription/FieldError opt into the Base UI part only when they detect a\n// surrounding `Field` (via `InsideFieldContext`) and otherwise render the plain\n// element they did before. Inside a Field they gain the automatic association;\n// outside one they are unchanged.\n//\n// `FieldSet` / `FieldLegend` stay native `