Skip to content

Accordion

accordion · Containers · interactive

Sections that open one at a time, or several.

Import

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

Example

Nothing is downloaded until you press it.

cpp
AccordionResult accordion(Ui& ui, const Interaction& input, std::string_view id, const std::vector<AccordionSection>& sections, AccordionState& state, const AccordionOptions& options = {});

A stack of collapsible sections. Enter or Space on a header opens it, the arrows move between headers, and Home and End reach the ends. Every header carries expanded, so a reader is told what a press will do before they make it.

API

AccordionOptions

OptionTypeDefaultWhat it does
exclusiveboolfalseOpening one closes the others. Off by default, and that is the less obvious choice: an accordion whose sections close each other cannot be used to compare two of them, and a reader who opens the second and loses the first will open both again one at a time. Turn it on when the sections are long enough that two of them on screen would be worse.
namestd::string_viewWhat the whole stack is, for a reader arriving at it.
gapfloat6.0f

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