Files
Checkmate/client/src/components/inputs/Checkbox.tsx
T

46 lines
1.3 KiB
TypeScript
Raw Normal View History

2025-11-13 13:47:26 -08:00
import { forwardRef } from "react";
import Checkbox from "@mui/material/Checkbox";
import type { CheckboxProps } from "@mui/material/Checkbox";
import { Square, SquareCheck } from "lucide-react";
import { useTheme } from "@mui/material/styles";
type CheckboxInputProps = CheckboxProps & {
label?: string;
};
export const CheckboxInput = forwardRef<HTMLInputElement, CheckboxInputProps>(
2025-11-24 18:54:52 +00:00
function CheckboxInput(
{ sx, ...props }: CheckboxInputProps,
ref: React.Ref<HTMLInputElement>
) {
2025-11-13 13:47:26 -08:00
const theme = useTheme();
return (
<Checkbox
{...props}
aria-label={props.label}
slotProps={{
input: {
ref: ref,
},
}}
icon={<Square size={16} strokeWidth={1.5} />}
checkedIcon={<SquareCheck size={16} strokeWidth={1.5} />}
sx={{
2025-12-08 19:55:29 +00:00
color: theme.palette.text.secondary,
2025-11-13 13:47:26 -08:00
"&.Mui-checked": {
2025-12-08 19:55:29 +00:00
color: theme.palette.primary.main,
2025-11-13 13:47:26 -08:00
},
"&:hover": { backgroundColor: "transparent" },
"& svg": {
stroke: "currentColor",
},
"& svg path, & svg line, & svg polyline, & svg rect": {
stroke: "currentColor",
fill: "none",
},
2025-11-24 18:54:52 +00:00
2025-11-13 13:47:26 -08:00
...sx,
}}
/>
);
}
);