60 lines
2.3 KiB
JavaScript
60 lines
2.3 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 FormatAlignJustifyIcon from '@mui/icons-material/FormatAlignJustify';
|
||
|
|
import ToggleButton, { toggleButtonClasses } from '@mui/material/ToggleButton';
|
||
|
|
import ToggleButtonGroup, {
|
||
|
|
toggleButtonGroupClasses,
|
||
|
|
} from '@mui/material/ToggleButtonGroup';
|
||
|
|
import { styled } from '@mui/material/styles';
|
||
|
|
|
||
|
|
const StyledToggleButtonGroup = styled(ToggleButtonGroup)(({ theme }) => ({
|
||
|
|
gap: '2rem',
|
||
|
|
[`& .${toggleButtonGroupClasses.firstButton}, & .${toggleButtonGroupClasses.middleButton}`]:
|
||
|
|
{
|
||
|
|
borderTopRightRadius: (theme.vars || theme).shape.borderRadius,
|
||
|
|
borderBottomRightRadius: (theme.vars || theme).shape.borderRadius,
|
||
|
|
},
|
||
|
|
[`& .${toggleButtonGroupClasses.lastButton}, & .${toggleButtonGroupClasses.middleButton}`]:
|
||
|
|
{
|
||
|
|
borderTopLeftRadius: (theme.vars || theme).shape.borderRadius,
|
||
|
|
borderBottomLeftRadius: (theme.vars || theme).shape.borderRadius,
|
||
|
|
borderLeft: `1px solid ${(theme.vars || theme).palette.divider}`,
|
||
|
|
},
|
||
|
|
[`& .${toggleButtonGroupClasses.lastButton}.${toggleButtonClasses.disabled}, & .${toggleButtonGroupClasses.middleButton}.${toggleButtonClasses.disabled}`]:
|
||
|
|
{
|
||
|
|
borderLeft: `1px solid ${(theme.vars || theme).palette.action.disabledBackground}`,
|
||
|
|
},
|
||
|
|
}));
|
||
|
|
|
||
|
|
export default function HorizontalSpacingToggleButton() {
|
||
|
|
const [alignment, setAlignment] = React.useState('left');
|
||
|
|
|
||
|
|
const handleAlignment = (event, newAlignment) => {
|
||
|
|
setAlignment(newAlignment);
|
||
|
|
};
|
||
|
|
|
||
|
|
return (
|
||
|
|
<StyledToggleButtonGroup
|
||
|
|
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>
|
||
|
|
<ToggleButton value="justify" aria-label="justified" disabled>
|
||
|
|
<FormatAlignJustifyIcon />
|
||
|
|
</ToggleButton>
|
||
|
|
</StyledToggleButtonGroup>
|
||
|
|
);
|
||
|
|
}
|