ToggleButton
Toggle buttons are used to represent the pressed state.
- Useful links:
StrataKit MUI modifications
Section titled “StrataKit MUI modifications”- A
labelprop has been added. When specified, it is used as the ToggleButton’s accessible name and is also shown in a tooltip on hover and focus. - A
labelPlacementprop has been added to control the placement of a tooltip that is shown when thelabelprop is specified. - ToggleButtons are styled to match the visual appearance of the IconButton component. Borders are displayed only when the buttons are wrapped in a
ToggleButtonGroup. Standalone ToggleButtons do not have borders. - ToggleButtons can now be rendered as regular Buttons to display text.
Examples
Section titled “Examples”Standalone
Section titled “Standalone”Use the selected and onChange props to control the selected state of a standalone ToggleButton when it is not nested within a ToggleButtonGroup component.
- Small: Use in compact interfaces where space is limited.
- Medium: Default size, suitable for most use cases.
- Large: Use in spacious layouts where a more prominent button is needed.
To display text within a ToggleButton, use the render prop to render a Button. Additionally, the label prop should be omitted, as the visible text already provides an accessible name.
- Use ToggleButton for actions that have an on/off state.
- Use the
labelprop in icon-only ToggleButtons to provide a descriptive, accessible name. - Use
ToggleButtonGroupto group multiple related ToggleButtons.
🚫 Don’t
Section titled “🚫 Don’t”- Don’t use to replace buttons.
- Don’t mix text and icon-only ToggleButtons in the same group.