Skip to content

Banner

banner · Elements · interactive

A message that stays, in the flow, where the thing it is about is.

Import

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

Example

Nothing is downloaded until you press it.

cpp
BannerResult banner(Ui& ui, const Interaction& input, std::string_view id, std::string_view title, const BannerOptions& options = {});

A message in the flow. Danger and Warning take ARIA's alert, which interrupts a screen reader mid-sentence; Info and Success take status, which waits for a pause. That difference is the whole reason the kind is not just a colour: a conflict a reader has to know about now and a note they can hear in a moment are not the same message.

API

BannerOptions

OptionTypeDefaultWhat it does
kindBannerKind
Info · Success · Warning · Danger
BannerKind::InfoHow much attention it is owed — and therefore whether a screen reader is interrupted by it. See BannerKind.
detailstd::string_viewA second line under the title, for the part that does not fit in one.
icon optionalstd::optional<Icon>Overrides the glyph the kind would pick.
closableboolfalseAn × at the trailing edge. A banner whose condition the reader cannot clear should not have one — an × that puts the message back next frame is a control that does not work.
actionstd::string_viewThe label of a single action at the trailing edge — "Resolve", "Retry", "Reload". Empty draws none.

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