Files
react-test/docs/data/joy/components/switch/ExampleStrapiSwitch.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

29 lines
815 B
JavaScript
Raw Normal View History

2025-12-12 14:26:25 +09:00
import * as React from 'react';
import Switch, { switchClasses } from '@mui/joy/Switch';
export default function ExampleStrapiSwitch() {
const [checked, setChecked] = React.useState(false);
return (
<Switch
color={checked ? 'success' : 'danger'}
checked={checked}
onChange={(event) => setChecked(event.target.checked)}
sx={{
'--Switch-thumbSize': '16px',
'--Switch-trackWidth': '40px',
'--Switch-trackHeight': '24px',
'--Switch-trackBackground': '#EE5E52',
'&:hover': {
'--Switch-trackBackground': '#EE5E52',
},
[`&.${switchClasses.checked}`]: {
'--Switch-trackBackground': '#5CB176',
'&:hover': {
'--Switch-trackBackground': '#5CB176',
},
},
}}
/>
);
}