el.xwx.moe/components/Checkbox.tsx

29 lines
737 B
TypeScript
Raw Normal View History

2023-05-15 14:18:33 -05:00
import { faSquare, faSquareCheck } from "@fortawesome/free-regular-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { ChangeEventHandler } from "react";
type Props = {
label: string;
state: boolean;
2023-05-18 13:02:17 -05:00
className?: string;
2023-05-15 14:18:33 -05:00
onClick: ChangeEventHandler<HTMLInputElement>;
};
2023-05-18 13:02:17 -05:00
export default function Checkbox({ label, state, className, onClick }: Props) {
2023-05-15 14:18:33 -05:00
return (
2023-10-28 11:50:11 -05:00
<label
2023-12-01 13:00:52 -06:00
className={`label cursor-pointer flex gap-2 justify-start ${
className || ""
}`}
2023-10-28 11:50:11 -05:00
>
2023-05-15 14:18:33 -05:00
<input
type="checkbox"
checked={state}
onChange={onClick}
2023-12-01 13:00:52 -06:00
className="checkbox checkbox-primary"
2023-05-15 14:18:33 -05:00
/>
2023-12-01 13:00:52 -06:00
<span className="label-text">{label}</span>
2023-05-15 14:18:33 -05:00
</label>
);
}