Skip to content

Chip

chip · Elements · interactive

A pill you can press, or take off.

Import

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

Example

Nothing is downloaded until you press it.

cpp
ChipResult chip(Ui& ui, const Interaction& input, std::string_view id, std::string_view label, const ChipOptions& options = {});

A pressable pill. Enter and Space press it; when it is removable, Delete and Backspace remove it while it has focus — which is the gesture every tag field on the web has and the reason a removable chip needs no pointer at all.

API

ChipOptions

OptionTypeDefaultWhat it does
selectedboolfalseDrawn as chosen: filled rather than outlined, and announced as pressed. This is what a filter chip is for. A chip that only ever looks the same is a label with a cursor on it.
removableboolfalseAn × at the trailing edge, and a second thing to press.
leading optionalstd::optional<Icon>A glyph before the label.
disabledboolfalse
namestd::string_viewWhat it is called, when the label is not enough on its own — "main" on a branch chip is a word, not a sentence.
colorTokenToken::Accent

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