ToggleButton
A toggle button: a Button that can be "pressed / unpressed".
Basic usage
The on/off state uses the checked / defaultChecked / onChange channels, and onChange's first argument is the new boolean state. A pressed button shows the active (highlighted) look.
Unframed form
Like Button it supports framed={false} and the various flags, commonly used for grouped toggles in a toolbar.
How it differs from Button
ToggleButton borrows Button's appearance but has no link capability: href / target / rel / anchorRef are not accepted, and active, onClick and aria-pressed are driven by the toggle state and not exposed. Use Button to "run an action once on click", and this component to "express a persistent on/off state".
API
onChange is a toggle callback and does not follow the value-first ChangeHandler signature (see Controlled and uncontrolled · Callback signatures).
See also
- Button's base capabilities and icon / indicator: Button
- The switch form: ToggleSwitch
- Arranging buttons into a group: ButtonGroup