Skip to content

Toggle

toggle · Elements · interactive

A switch.

Import

cpp
#include "gbui/widgets/toggle.hpp"

Example

Nothing is downloaded until you press it.

cpp
[[nodiscard]] bool toggle(Ui& ui, const Interaction& input, std::string_view id, bool on, const ToggleOptions& options = {});

Same contract as the checkbox; the difference is only that a switch reads as "on now" and a checkbox as "will apply".

API

ToggleOptions

OptionTypeDefaultWhat it does
disabledboolfalse
labelstd::string_view
namestd::string_viewWhat a reader is told this is, when the label is not it. The label by default, which is right whenever there is one. Needed where the words are drawn beside the control rather than by it — a row that lays out its own caption and passes an empty label — because then there is nothing for the control to borrow and "switch, on" is all a reader gets.
widthfloat0.0fZero takes the active design's track and thumb.
heightfloat0.0f

Released under the LGPL-3.0-or-later licence.