import { useId } from 'react'
import type { ReactNode } from 'react'
import { Check } from 'lucide-react'
interface Props {
checked: boolean
onChange: (checked: boolean) => void
/** Visible label rendered next to the box. Pass empty string for an icon-only checkbox. */
label?: ReactNode
/** Helper text below the label. */
description?: ReactNode
disabled?: boolean
/** When true, no visible label is rendered — but `aria-label` must be provided. */
hideLabel?: boolean
ariaLabel?: string
/** Extra class on the outer label/wrapper. */
className?: string
/** ID for the underlying input — defaults to a generated one. */
id?: string
}
/**
* Design-system checkbox. A real `` (visually hidden)
* with a rendered box + check glyph so styling is consistent across browsers
* and brand-recoloring works through CSS variables.
*/
export default function Checkbox({
checked,
onChange,
label,
description,
disabled,
hideLabel,
ariaLabel,
className,
id,
}: Props) {
const generatedId = useId()
const inputId = id ?? generatedId
const descId = description ? `${inputId}-desc` : undefined
const visibleLabel = !hideLabel && label !== undefined && label !== ''
return (
)
}