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
74 lines
2.5 KiB
TypeScript
74 lines
2.5 KiB
TypeScript
import * as React from 'react';
|
|
import Box from '@mui/joy/Box';
|
|
import Radio, { radioClasses } from '@mui/joy/Radio';
|
|
import RadioGroup from '@mui/joy/RadioGroup';
|
|
import FormatAlignCenterIcon from '@mui/icons-material/FormatAlignCenter';
|
|
import FormatAlignJustifyIcon from '@mui/icons-material/FormatAlignJustify';
|
|
import FormatAlignLeftIcon from '@mui/icons-material/FormatAlignLeft';
|
|
import FormatAlignRightIcon from '@mui/icons-material/FormatAlignRight';
|
|
|
|
export default function ExampleAlignmentButtons() {
|
|
const [alignment, setAlignment] = React.useState('left');
|
|
return (
|
|
<RadioGroup
|
|
orientation="horizontal"
|
|
aria-label="Alignment"
|
|
name="alignment"
|
|
variant="outlined"
|
|
value={alignment}
|
|
onChange={(event: React.ChangeEvent<HTMLInputElement>) =>
|
|
setAlignment(event.target.value)
|
|
}
|
|
sx={{ display: 'inline-flex' }}
|
|
>
|
|
{['left', 'center', 'right', 'justify'].map((item) => (
|
|
<Box
|
|
key={item}
|
|
sx={(theme) => ({
|
|
position: 'relative',
|
|
display: 'flex',
|
|
justifyContent: 'center',
|
|
alignItems: 'center',
|
|
width: 48,
|
|
height: 48,
|
|
'&:not([data-first-child])': {
|
|
borderLeft: '1px solid',
|
|
borderColor: 'divider',
|
|
},
|
|
[`&[data-first-child] .${radioClasses.action}`]: {
|
|
borderTopLeftRadius: `calc(${theme.vars.radius.sm} - 1px)`,
|
|
borderBottomLeftRadius: `calc(${theme.vars.radius.sm} - 1px)`,
|
|
},
|
|
[`&[data-last-child] .${radioClasses.action}`]: {
|
|
borderTopRightRadius: `calc(${theme.vars.radius.sm} - 1px)`,
|
|
borderBottomRightRadius: `calc(${theme.vars.radius.sm} - 1px)`,
|
|
},
|
|
})}
|
|
>
|
|
<Radio
|
|
value={item}
|
|
disableIcon
|
|
overlay
|
|
label={
|
|
{
|
|
left: <FormatAlignLeftIcon />,
|
|
right: <FormatAlignRightIcon />,
|
|
center: <FormatAlignCenterIcon />,
|
|
justify: <FormatAlignJustifyIcon />,
|
|
}[item]
|
|
}
|
|
variant={alignment === item ? 'solid' : 'plain'}
|
|
slotProps={{
|
|
input: { 'aria-label': item },
|
|
action: {
|
|
sx: { borderRadius: 0, transition: 'none' },
|
|
},
|
|
label: { sx: { lineHeight: 0 } },
|
|
}}
|
|
/>
|
|
</Box>
|
|
))}
|
|
</RadioGroup>
|
|
);
|
|
}
|