{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "checkbox-group", "type": "registry:ui", "title": "Checkbox Group", "description": "A group of checkboxes for multi-selection with horizontal or vertical layout.", "dependencies": [ "motion" ], "files": [ { "path": "registry/ruixenui/checkbox-group.tsx", "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { cn } from \"@/lib/utils\";\nimport { motion, AnimatePresence } from \"motion/react\";\n\ninterface CheckboxOption {\n value: string;\n label: string;\n description?: string;\n disabled?: boolean;\n}\n\ninterface CheckboxGroupProps {\n options: CheckboxOption[];\n value?: string[];\n defaultValue?: string[];\n onValueChange?: (value: string[]) => void;\n label?: string;\n orientation?: \"horizontal\" | \"vertical\";\n className?: string;\n}\n\nexport function CheckboxGroup({\n options,\n value,\n defaultValue = [],\n onValueChange,\n label,\n orientation = \"vertical\",\n className,\n}: CheckboxGroupProps) {\n const [internalValue, setInternalValue] =\n React.useState(defaultValue);\n const isControlled = value !== undefined;\n const selectedValues = isControlled ? value : internalValue;\n\n const handleChange = (optionValue: string, checked: boolean) => {\n const newValue = checked\n ? [...selectedValues, optionValue]\n : selectedValues.filter((v) => v !== optionValue);\n\n if (!isControlled) {\n setInternalValue(newValue);\n }\n onValueChange?.(newValue);\n };\n\n return (\n
\n {label && (\n \n {label}\n \n )}\n \n {options.map((option) => {\n const isChecked = selectedValues.includes(option.value);\n const inputId = `checkbox-group-${option.value}`;\n\n return (\n \n
\n handleChange(option.value, e.target.checked)}\n disabled={option.disabled}\n className=\"peer sr-only\"\n />\n \n \n {isChecked && (\n \n \n \n )}\n \n \n
\n
\n \n {option.label}\n \n {option.description && (\n \n {option.description}\n \n )}\n
\n \n );\n })}\n
\n \n );\n}\n", "type": "registry:ui", "target": "components/ruixen/checkbox-group.tsx" } ] }