{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "form-field-wrapper", "type": "registry:lib", "title": "Form Field Wrapper", "description": "Unified wrapper for form controls with label, validation states, and messages.\n * Eliminates code duplication across InputGlass, SliderGlass, ComboBoxGlass, etc.\n *\n * Handles:", "dependencies": [ "react" ], "registryDependencies": [ "cn" ], "files": [ { "path": "components/glass/primitives/form-field-wrapper.tsx", "type": "registry:lib", "content": "/**\n * FormFieldWrapper Component\n *\n * Unified wrapper for form controls with label, validation states, and messages.\n * Eliminates code duplication across InputGlass, SliderGlass, ComboBoxGlass, etc.\n *\n * Handles:\n * - Label with optional required indicator\n * - Error messages (highest priority, red)\n * - Success messages (green, shown if no error)\n * - Consistent spacing and typography\n */\n\nimport { forwardRef, type ReactNode, type HTMLAttributes } from 'react';\nimport { cn } from '@/lib/utils';\n\n/**\n * Props for the FormFieldWrapper component\n */\nexport interface FormFieldWrapperProps extends HTMLAttributes {\n /**\n * Label text displayed above the field\n */\n label?: string;\n\n /**\n * Error message - takes priority over success\n * Displays in red below the field\n */\n error?: string;\n\n /**\n * Success message - displays in green if no error\n * Displays below the field\n */\n success?: string;\n\n /**\n * ID to link label with input via htmlFor\n * Should match the input's id attribute\n */\n htmlFor?: string;\n\n /**\n * Shows red asterisk (*) next to label\n * @default false\n */\n required?: boolean;\n\n /**\n * The form control element(s) to wrap\n */\n children: ReactNode;\n}\n\n/**\n * FormFieldWrapper component\n *\n * Provides consistent structure for form fields with labels and validation messages.\n * Used by InputGlass, SliderGlass, and other form components.\n *\n * @example\n * ```tsx\n * // Basic usage\n * \n * \n * \n *\n * // With validation\n * \n * \n * \n *\n * // Success state\n * \n * \n * \n * ```\n */\nexport const FormFieldWrapper = forwardRef(\n (\n {\n label,\n error,\n success,\n htmlFor,\n required,\n className,\n children,\n ...props\n },\n ref\n ) => {\n return (\n \n {label && (\n \n {label}\n {required && (\n \n *\n \n )}\n \n )}\n\n {children}\n\n {error && (\n \n {error}\n

\n )}\n\n {success && !error && (\n \n {success}\n

\n )}\n \n );\n }\n);\n\nFormFieldWrapper.displayName = 'FormFieldWrapper';\n" } ], "categories": [ "primitives" ] }