Toggle Button
Stays visually pressed until clicked again — bind pressed to a RwSignal<bool> for toolbar modes like bold or italic.
The control sets aria-pressed and swaps appearance between subtle and secondary. Label text should communicate both the action and current state (for example, "Bold, on"). For settings that apply immediately, prefer Switch; for grouped exclusive choices, compose multiple toggles manually until a group wrapper ships.
- Rich text toolbar actions (bold, italic, underline)
- View mode switches that are not instant settings
- Binary states where pressed appearance should persist
- Bind
pressedto a boolean signal for two-way toggle state. - Optionally pass
on_clickto react when the pressed state changes. - Put label text in children.
Starts unpressed; each click toggles the pressed state and updates aria-pressed.
Initial pressed state for formatting actions that are already active in the editor.
Two-way binding keeps the pressed signal in sync as users click the control on and off.
Optional callback runs after each toggle with the new pressed value for app-side reactions.