CustomSwitch.tsx 911 B

123456789101112131415161718192021222324252627282930313233343536
  1. import FormControlLabel from '@mui/material/FormControlLabel';
  2. import Switch from '@mui/material/Switch';
  3. import { FC } from 'react';
  4. import { useTranslation } from 'react-i18next';
  5. import { makeStyles } from '@mui/styles';
  6. import type { Theme } from '@mui/material/styles';
  7. import type { CustomSwitchProps } from './Types';
  8. const getStyles = makeStyles((theme: Theme) => ({
  9. label: {
  10. color: '#757575',
  11. },
  12. placement: {
  13. marginLeft: 0,
  14. },
  15. }));
  16. const CustomSwitch: FC<CustomSwitchProps> = ({ onChange }) => {
  17. const classes = getStyles();
  18. const { t: commonTrans } = useTranslation();
  19. return (
  20. <FormControlLabel
  21. classes={{
  22. label: classes.label,
  23. labelPlacementStart: classes.placement,
  24. }}
  25. label={commonTrans('view')}
  26. labelPlacement="start"
  27. control={<Switch color="primary" onChange={onChange} />}
  28. />
  29. );
  30. };
  31. export default CustomSwitch;