Files
Checkmate/client/src/Components/inputs/Switch.tsx
T

39 lines
862 B
TypeScript
Raw Normal View History

2026-01-29 23:10:34 +00:00
import { forwardRef } from "react";
import Switch from "@mui/material/Switch";
import type { SwitchProps } from "@mui/material/Switch";
import { useTheme } from "@mui/material/styles";
2026-02-02 21:51:06 +00:00
interface SwitchComponentProps extends SwitchProps {
dualOption?: boolean;
}
export const SwitchComponent = forwardRef<HTMLInputElement, SwitchComponentProps>(
function SwitchComponent({ sx, dualOption = false, ...props }, ref) {
2026-01-29 23:10:34 +00:00
const theme = useTheme();
const additionalSx = Array.isArray(sx) ? sx : sx ? [sx] : [];
return (
<Switch
{...props}
slotProps={{
input: {
ref: ref,
},
}}
sx={[
...(dualOption
? [
{
"& .MuiSwitch-track": {
backgroundColor: theme.palette.primary.main,
opacity: 1,
},
2026-01-29 23:10:34 +00:00
},
]
: []),
2026-01-29 23:10:34 +00:00
...additionalSx,
]}
/>
);
}
);