{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "checkbox-indeterminate", "type": "registry:ui", "title": "Checkbox Indeterminate", "description": "A checkbox with three states: checked, unchecked, and indeterminate.", "dependencies": [ "motion" ], "files": [ { "path": "registry/ruixenui/checkbox-indeterminate.tsx", "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { cn } from \"@/lib/utils\";\nimport { motion, AnimatePresence } from \"motion/react\";\n\ntype CheckedState = boolean | \"indeterminate\";\n\ninterface CheckboxIndeterminateProps {\n checked?: CheckedState;\n defaultChecked?: CheckedState;\n onCheckedChange?: (checked: CheckedState) => void;\n label?: string;\n disabled?: boolean;\n id?: string;\n className?: string;\n}\n\nexport function CheckboxIndeterminate({\n checked,\n defaultChecked = false,\n onCheckedChange,\n label,\n disabled = false,\n id,\n className,\n}: CheckboxIndeterminateProps) {\n const [internalChecked, setInternalChecked] =\n React.useState(defaultChecked);\n const isControlled = checked !== undefined;\n const currentState = isControlled ? checked : internalChecked;\n const inputId = id || React.useId();\n const inputRef = React.useRef(null);\n\n React.useEffect(() => {\n if (inputRef.current) {\n inputRef.current.indeterminate = currentState === \"indeterminate\";\n }\n }, [currentState]);\n\n const handleChange = () => {\n const newState = currentState === true ? false : true;\n if (!isControlled) {\n setInternalChecked(newState);\n }\n onCheckedChange?.(newState);\n };\n\n const isChecked = currentState === true;\n const isIndeterminate = currentState === \"indeterminate\";\n const isFilled = isChecked || isIndeterminate;\n\n return (\n \n
\n \n \n \n {isChecked && (\n \n \n \n )}\n {isIndeterminate && (\n \n \n \n )}\n \n \n
\n {label && (\n \n {label}\n \n )}\n \n );\n}\n", "type": "registry:ui", "target": "components/ruixen/checkbox-indeterminate.tsx" } ] }