'use client'; import * as React from 'react'; import { Checkbox as CheckboxPrimitive } from '@base-ui-components/react/checkbox'; import { type HTMLMotionProps, motion } from 'motion/react'; import { cn } from '@workspace/ui/lib/utils'; type CheckboxProps = Omit< React.ComponentProps, 'render' > & { motionProps?: HTMLMotionProps<'button'>; }; function Checkbox({ className, onCheckedChange, motionProps, ...props }: CheckboxProps) { const [isChecked, setIsChecked] = React.useState( props?.checked ?? props?.defaultChecked ?? false, ); React.useEffect(() => { if (props?.checked !== undefined) setIsChecked(props.checked); }, [props?.checked]); const handleCheckedChange = React.useCallback( (checked: boolean, event: Event) => { setIsChecked(checked); onCheckedChange?.(checked, event); }, [onCheckedChange], ); return ( } > ); } Checkbox.displayName = CheckboxPrimitive.Root.displayName; export { Checkbox, type CheckboxProps };