Files
react-test/docs/data/material/components/toggle-button/ToggleButtonSizes.tsx
how2ice 005cf56baf
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
init project
2025-12-12 14:26:25 +09:00

55 lines
1.7 KiB
TypeScript

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 Stack from '@mui/material/Stack';
import ToggleButton from '@mui/material/ToggleButton';
import ToggleButtonGroup from '@mui/material/ToggleButtonGroup';
export default function ToggleButtonSizes() {
const [alignment, setAlignment] = React.useState('left');
const handleChange = (
event: React.MouseEvent<HTMLElement>,
newAlignment: string,
) => {
setAlignment(newAlignment);
};
const children = [
<ToggleButton value="left" key="left">
<FormatAlignLeftIcon />
</ToggleButton>,
<ToggleButton value="center" key="center">
<FormatAlignCenterIcon />
</ToggleButton>,
<ToggleButton value="right" key="right">
<FormatAlignRightIcon />
</ToggleButton>,
<ToggleButton value="justify" key="justify">
<FormatAlignJustifyIcon />
</ToggleButton>,
];
const control = {
value: alignment,
onChange: handleChange,
exclusive: true,
};
return (
<Stack spacing={2} sx={{ alignItems: 'center' }}>
<ToggleButtonGroup size="small" {...control} aria-label="Small sizes">
{children}
</ToggleButtonGroup>
<ToggleButtonGroup {...control} aria-label="Medium sizes">
{children}
</ToggleButtonGroup>
<ToggleButtonGroup size="large" {...control} aria-label="Large sizes">
{children}
</ToggleButtonGroup>
</Stack>
);
}