Files
react-test/docs/data/material/customization/how-to-customize/DynamicCSS.js
how2ice 005cf56baf
Some checks failed
No response / noResponse (push) Has been cancelled
CI / Continuous releases (push) Has been cancelled
CI / test-dev (macos-latest) (push) Has been cancelled
CI / test-dev (ubuntu-latest) (push) Has been cancelled
CI / test-dev (windows-latest) (push) Has been cancelled
Maintenance / main (push) Has been cancelled
Scorecards supply-chain security / Scorecards analysis (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
init project
2025-12-12 14:26:25 +09:00

53 lines
1.3 KiB
JavaScript

import * as React from 'react';
import { alpha, styled } from '@mui/material/styles';
import Slider from '@mui/material/Slider';
import FormControlLabel from '@mui/material/FormControlLabel';
import Switch from '@mui/material/Switch';
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) => {
setSuccess(event.target.checked);
};
return (
<React.Fragment>
<FormControlLabel
control={
<Switch
checked={success}
onChange={handleChange}
color="primary"
value="dynamic-class-name"
/>
}
label="Success"
/>
<StyledSlider success={success} defaultValue={30} sx={{ mt: 1 }} />
</React.Fragment>
);
}