65 lines
2.0 KiB
JavaScript
65 lines
2.0 KiB
JavaScript
|
|
import * as React from 'react';
|
||
|
|
import FormatAlignLeftIcon from '@mui/icons-material/FormatAlignLeft';
|
||
|
|
import FormatAlignCenterIcon from '@mui/icons-material/FormatAlignCenter';
|
||
|
|
import FormatAlignRightIcon from '@mui/icons-material/FormatAlignRight';
|
||
|
|
import LaptopIcon from '@mui/icons-material/Laptop';
|
||
|
|
import TvIcon from '@mui/icons-material/Tv';
|
||
|
|
import PhoneAndroidIcon from '@mui/icons-material/PhoneAndroid';
|
||
|
|
import Stack from '@mui/material/Stack';
|
||
|
|
import ToggleButton from '@mui/material/ToggleButton';
|
||
|
|
import ToggleButtonGroup from '@mui/material/ToggleButtonGroup';
|
||
|
|
|
||
|
|
export default function ToggleButtonNotEmpty() {
|
||
|
|
const [alignment, setAlignment] = React.useState('left');
|
||
|
|
const [devices, setDevices] = React.useState(() => ['phone']);
|
||
|
|
|
||
|
|
const handleAlignment = (event, newAlignment) => {
|
||
|
|
if (newAlignment !== null) {
|
||
|
|
setAlignment(newAlignment);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
const handleDevices = (event, newDevices) => {
|
||
|
|
if (newDevices.length) {
|
||
|
|
setDevices(newDevices);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
return (
|
||
|
|
<Stack direction="row" spacing={4}>
|
||
|
|
<ToggleButtonGroup
|
||
|
|
value={alignment}
|
||
|
|
exclusive
|
||
|
|
onChange={handleAlignment}
|
||
|
|
aria-label="text alignment"
|
||
|
|
>
|
||
|
|
<ToggleButton value="left" aria-label="left aligned">
|
||
|
|
<FormatAlignLeftIcon />
|
||
|
|
</ToggleButton>
|
||
|
|
<ToggleButton value="center" aria-label="centered">
|
||
|
|
<FormatAlignCenterIcon />
|
||
|
|
</ToggleButton>
|
||
|
|
<ToggleButton value="right" aria-label="right aligned">
|
||
|
|
<FormatAlignRightIcon />
|
||
|
|
</ToggleButton>
|
||
|
|
</ToggleButtonGroup>
|
||
|
|
|
||
|
|
<ToggleButtonGroup
|
||
|
|
value={devices}
|
||
|
|
onChange={handleDevices}
|
||
|
|
aria-label="device"
|
||
|
|
>
|
||
|
|
<ToggleButton value="laptop" aria-label="laptop">
|
||
|
|
<LaptopIcon />
|
||
|
|
</ToggleButton>
|
||
|
|
<ToggleButton value="tv" aria-label="tv">
|
||
|
|
<TvIcon />
|
||
|
|
</ToggleButton>
|
||
|
|
<ToggleButton value="phone" aria-label="phone">
|
||
|
|
<PhoneAndroidIcon />
|
||
|
|
</ToggleButton>
|
||
|
|
</ToggleButtonGroup>
|
||
|
|
</Stack>
|
||
|
|
);
|
||
|
|
}
|