because I got bored of customising my CV for every job
1import { cn } from "../lib/cn";
2
3interface CheckboxProps {
4 label?: string;
5 checked?: boolean;
6 onChange?: (checked: boolean) => void;
7 disabled?: boolean;
8 className?: string;
9 id?: string;
10}
11
12export const Checkbox = ({
13 label,
14 checked = false,
15 onChange,
16 disabled = false,
17 className = "",
18 id,
19}: CheckboxProps) => {
20 const checkboxId =
21 id || (label ? label.toLowerCase().replace(/\s+/g, "-") : undefined);
22
23 return (
24 <div className="flex items-center space-x-2">
25 <input
26 id={checkboxId}
27 type="checkbox"
28 checked={checked}
29 onChange={(e) => onChange?.(e.target.checked)}
30 disabled={disabled}
31 className={cn(
32 "h-4 w-4 rounded border-ctp-surface1 bg-transparent text-ctp-blue focus:ring-2 focus:ring-ctp-blue focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
33 className,
34 )}
35 />
36 {label && (
37 <label
38 htmlFor={checkboxId}
39 className="text-sm font-medium text-ctp-text cursor-pointer"
40 >
41 {label}
42 </label>
43 )}
44 </div>
45 );
46};