40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import { Check } from "lucide-react";
|
|
import { type InputHTMLAttributes, type ReactNode } from "react";
|
|
|
|
type CheckboxProps = InputHTMLAttributes<HTMLInputElement> & {
|
|
label: ReactNode;
|
|
labelStyle?: string;
|
|
error?: string;
|
|
};
|
|
|
|
export default function Checkbox({
|
|
label,
|
|
checked,
|
|
error,
|
|
className = "",
|
|
labelStyle = "text-small",
|
|
...props
|
|
}: Readonly<CheckboxProps>) {
|
|
return (
|
|
<label className="flex cursor-pointer items-start gap-3">
|
|
<span className="relative mt-1 h-[30px] w-[30px] shrink-0">
|
|
<input
|
|
type="checkbox"
|
|
checked={checked}
|
|
{...props}
|
|
className={`peer absolute inset-0 h-full w-full cursor-pointer appearance-none rounded-[10px] border-4 bg-white ${className}
|
|
${error ? "border-rouge" : "border-bleu"}`}
|
|
/>
|
|
<Check
|
|
size={18}
|
|
strokeWidth={3}
|
|
className="pointer-events-none absolute inset-0 m-auto text-bleu opacity-0 peer-checked:opacity-100"
|
|
/>
|
|
</span>
|
|
|
|
<span className={`font-poppins-light ${labelStyle} text-bleu`}>
|
|
{label}
|
|
</span>
|
|
</label>
|
|
);
|
|
}
|