forked from mui/material-ui
/
SwitchControl.js
35 lines (34 loc) · 1010 Bytes
/
SwitchControl.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import * as React from 'react';
import Box from '@mui/joy/Box';
import FormControl from '@mui/joy/FormControl';
import FormLabel from '@mui/joy/FormLabel';
import FormHelperText from '@mui/joy/FormHelperText';
import Switch from '@mui/joy/Switch';
export default function SwitchLabel() {
const [checked, setChecked] = React.useState(false);
return (
<FormControl
orientation="horizontal"
sx={{ width: 300, justifyContent: 'space-between' }}
>
<Box>
<FormLabel>Show captions</FormLabel>
<FormHelperText sx={{ mt: 0 }}>All languages available.</FormHelperText>
</Box>
<Switch
checked={checked}
onChange={(event) => setChecked(event.target.checked)}
color={checked ? 'success' : 'neutral'}
variant="outlined"
endDecorator={checked ? 'On' : 'Off'}
slotProps={{
endDecorator: {
sx: {
minWidth: 24,
},
},
}}
/>
</FormControl>
);
}