Toggle Buttons
Toggle buttons can be used to group related options.
To emphasize groups of related Toggle buttons, a group should share a common container.
The ToggleButtonGroup
will control the selected state of its child buttons when
given its own value
prop.
Exclusive Selection
Text justification toggle buttons present options for left, right, center, full, and justified text with only one item available for selection at a time. Selecting one option deselects any other.
Multiple Selection
Logically-grouped options, like Bold, Italic, and Underline, allow multiple options to be selected.
<Grid container spacing={2} direction="column" alignItems="center">
<Grid item>
<ToggleButtonGroup size="small" value={alignment} exclusive onChange={handleChange}>
{children}
</ToggleButtonGroup>
</Grid>
<Grid item>
<ToggleButtonGroup size="medium" value={alignment} exclusive onChange={handleChange}>
{children}
</ToggleButtonGroup>
</Grid>
<Grid item>
<ToggleButtonGroup size="large" value={alignment} exclusive onChange={handleChange}>
{children}
</ToggleButtonGroup>
</Grid>
</Grid>
<ToggleButton
value="check"
selected={selected}
onChange={() => {
setSelected(!selected);
}}
>
<CheckIcon />
</ToggleButton>
Customized toggle button
Here is an example of customizing the component. You can learn more about this in the overrides documentation page.