{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "checkbox-glass", "type": "registry:ui", "title": "Checkbox Glass", "description": "Glass-themed checkbox built on Radix UI primitives with:", "dependencies": [ "@radix-ui/react-checkbox", "lucide-react", "react", "shadcn-glass-ui" ], "registryDependencies": [ "cn" ], "files": [ { "path": "components/glass/ui/checkbox-glass.tsx", "type": "registry:component", "content": "/**\n * CheckboxGlass Component\n *\n * Glass-themed checkbox built on Radix UI primitives with:\n * - 100% shadcn/ui type compatibility\n * - Theme-aware styling (glass/light/aurora)\n * - Glow effect on hover/focus\n * - Optional label\n *\n * @since v2.2.6 - Migrated to Radix UI primitives for full type compatibility\n */\n\nimport * as React from 'react';\nimport * as CheckboxPrimitive from '@radix-ui/react-checkbox';\nimport { Check, Minus } from 'lucide-react';\nimport { cn } from '@/lib/utils';\nimport '@/glass-theme.css';\n\n// ========================================\n// TYPES\n// ========================================\n\n/**\n * Checked state type compatible with shadcn/ui (Radix UI)\n */\nexport type CheckedState = boolean | 'indeterminate';\n\n/**\n * Props for the CheckboxGlass component\n *\n * Extends Radix UI Checkbox.Root props for 100% shadcn/ui compatibility.\n * All Radix props are supported including: checked, defaultChecked, onCheckedChange,\n * disabled, required, name, value, etc.\n *\n * **Type Compatibility (v2.3.1+):**\n * - Extends `React.ComponentPropsWithoutRef`\n * - No more `as unknown as` type assertions needed\n * - Full IntelliSense for all Radix props\n *\n * @accessibility\n * - **Keyboard Navigation:** Space to toggle (WCAG 2.1.1)\n * - **Focus Management:** Visible focus ring using `--focus-glow` CSS variable (WCAG 2.4.7)\n * - **Screen Readers:** Radix UI handles ARIA attributes automatically\n * - **Touch Targets:** 44x44px minimum touch area per Apple HIG (WCAG 2.5.5)\n * - **Color Contrast:** Check mark and backgrounds meet WCAG AA contrast ratio 4.5:1\n *\n * @example\n * ```tsx\n * // shadcn/ui compatible API\n * setIsChecked(checked === true)}\n * />\n *\n * // Indeterminate state (tri-state checkbox)\n * {\n * if (checked === true) selectAll();\n * else deselectAll();\n * }}\n * label=\"Select all\"\n * />\n *\n * // Legacy API (still supported)\n * \n * ```\n *\n * @since v2.3.0 - Added shadcn/ui compatible `onCheckedChange` and `indeterminate` support\n * @since v2.2.6 - Migrated to Radix UI primitives for full type compatibility\n */\nexport interface CheckboxGlassProps extends Omit<\n React.ComponentPropsWithoutRef,\n 'onChange'\n> {\n /**\n * @deprecated Use `onCheckedChange` instead. Will be removed in v4.0.\n * Legacy callback for backwards compatibility.\n */\n readonly onChange?: (checked: boolean) => void;\n /** Optional label text (Glass UI extension) */\n readonly label?: string;\n /**\n * className for the wrapper label element.\n * Use this for spacing, layout, or wrapper-specific styling.\n * Note: `className` applies to the checkbox root element (shadcn/ui pattern).\n * @since v2.6.0\n */\n readonly wrapperClassName?: string;\n}\n\n// ========================================\n// COMPONENT\n// ========================================\n\nexport const CheckboxGlass = React.forwardRef<\n React.ElementRef,\n CheckboxGlassProps\n>(\n (\n { className, label, wrapperClassName, onChange, onCheckedChange, disabled, checked, ...props },\n ref\n ) => {\n // Wrapper for legacy onChange callback\n const handleCheckedChange = React.useCallback(\n (newChecked: CheckedState) => {\n onCheckedChange?.(newChecked);\n // Legacy support (deprecated)\n if (onChange && typeof newChecked === 'boolean') {\n onChange(newChecked);\n }\n },\n [onCheckedChange, onChange]\n );\n\n // Determine visual states\n const isIndeterminate = checked === 'indeterminate';\n const isChecked = checked === true;\n const showIndicator = isChecked || isIndeterminate;\n\n // Inline styles for CSS variables (matches original implementation)\n const checkboxStyles: React.CSSProperties = {\n background: showIndicator ? 'var(--checkbox-checked-bg)' : 'var(--checkbox-bg)',\n borderColor: showIndicator ? 'var(--checkbox-checked-bg)' : 'var(--checkbox-border)',\n };\n\n return (\n \n {/* Touch area wrapper - 44px minimum for Apple HIG compliance */}\n \n \n \n {isIndeterminate ? (\n \n ) : (\n \n )}\n \n \n \n {label && (\n \n {label}\n \n )}\n \n );\n }\n);\n\nCheckboxGlass.displayName = 'CheckboxGlass';\n\n/**\n * Checkbox - shadcn/ui compatible alias for CheckboxGlass\n *\n * @example\n * ```tsx\n * import { Checkbox } from 'shadcn-glass-ui'\n *\n * setIsChecked(checked === true)}\n * />\n * ```\n *\n * @since v2.3.0\n */\nexport const Checkbox = CheckboxGlass;\n" } ], "categories": [ "ui" ], "cssVars": { "light": { "--glass-bg": "rgba(255, 255, 255, 0.1)", "--glass-border": "rgba(255, 255, 255, 0.2)", "--blur-sm": "8px", "--blur-md": "16px", "--blur-lg": "24px" }, "dark": { "--glass-bg": "rgba(255, 255, 255, 0.05)", "--glass-border": "rgba(255, 255, 255, 0.1)", "--blur-sm": "8px", "--blur-md": "16px", "--blur-lg": "24px" } } }