Spaces:
Runtime error
Runtime error
File size: 1,106 Bytes
cd8bd0a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | "use client";
import { cn } from "@/shared/utils/cn";
interface CheckboxProps extends React.InputHTMLAttributes<HTMLInputElement> {
label?: React.ReactNode;
}
/**
* Checkbox — token-driven native checkbox (brand accent + keyboard focus ring).
* Replaces the ad-hoc `<input type="checkbox" style={{ accentColor: "#6366f1" }}>`
* pattern scattered across the dashboard. Optional `label` wraps it in a clickable row.
*/
export default function Checkbox({ label, className, id, ...props }: CheckboxProps) {
const box = (
<input
type="checkbox"
id={id}
className={cn(
"h-4 w-4 shrink-0 cursor-pointer rounded-[4px] accent-[var(--color-accent)]",
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/30",
"disabled:cursor-not-allowed disabled:opacity-50",
className
)}
{...props}
/>
);
if (!label) return box;
return (
<label
htmlFor={id}
className="inline-flex items-center gap-2 cursor-pointer text-sm text-text-main"
>
{box}
<span>{label}</span>
</label>
);
}
|