// shadcn-style Checkbox — native `` (no Radix dep)
// with indeterminate support. Drives the check / dash glyphs purely via
// CSS peer variants so it can't desync from the input's real state.
import { useEffect, useRef, type InputHTMLAttributes, type ReactNode } from 'react'
import { cn } from '../cn'
export interface CheckboxProps extends InputHTMLAttributes {
/** Tri-state middle: renders a dash. Wired to the DOM `indeterminate`
* property (not an attribute) via a ref effect. */
readonly indeterminate?: boolean
}
export const Checkbox = ({ className, indeterminate, ...props }: CheckboxProps): ReactNode => {
const ref = useRef(null)
useEffect(() => {
if (ref.current) ref.current.indeterminate = indeterminate === true
}, [indeterminate])
return (
{/* checkmark — visible only when checked (and not indeterminate) */}
{/* indeterminate dash */}
)
}