import * as React from 'react'; import { alpha, styled } from '@mui/material/styles'; import Slider, { SliderProps } from '@mui/material/Slider'; import FormControlLabel from '@mui/material/FormControlLabel'; import Switch from '@mui/material/Switch'; interface StyledSliderProps extends SliderProps { success?: boolean; } const StyledSlider = styled(Slider, { shouldForwardProp: (prop) => prop !== 'success', })(({ theme }) => ({ width: 300, variants: [ { props: ({ success }) => success, style: { color: theme.palette.success.main, '& .MuiSlider-thumb': { [`&:hover, &.Mui-focusVisible`]: { boxShadow: `0px 0px 0px 8px ${alpha(theme.palette.success.main, 0.16)}`, }, [`&.Mui-active`]: { boxShadow: `0px 0px 0px 14px ${alpha(theme.palette.success.main, 0.16)}`, }, }, }, }, ], })); export default function DynamicCSS() { const [success, setSuccess] = React.useState(false); const handleChange = (event: React.ChangeEvent) => { setSuccess(event.target.checked); }; return ( } label="Success" /> ); }