Skip to content

Spinner

spinner · Elements

A circle that turns while something is happening.

Import

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

Example

Nothing is downloaded until you press it.

cpp
NodeId spinner(Ui& ui, const SpinnerOptions& options = {});

A turning ring.

API

SpinnerOptions

OptionTypeDefaultWhat it does
sizefloat16.0f
thicknessfloat0.0fHow thick the ring is. Zero takes a sixth of size, which keeps a large spinner from looking like a hairline and a small one from looking like a doughnut.
colorTokenToken::Accent
trackTokenToken::BorderThe part of the ring that is not the moving arc, behind it.
namestd::string_viewWhat is happening — "Cloning", "Signing in". Announced as a live region, because a spinner is the one control whose whole meaning is invisible to a reader who cannot see it turning. Empty says nothing at all, which is right when the surrounding text already says it or when a busy state on the container does.
phasefloat0.0fWhere in its turn it is, in turns. Feed it a clock. The caller's, exactly as progressBar's indeterminate form takes it, and for the same reason: a component here holds no state, and "how long has this been spinning" is state. One turn per second is time; half that speed is time * 0.5f. The fractional part is all that is read, so a clock that never resets is fine.

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