Widgets

A widget shows one field of your model and lets the user change it. You never create a widget yourself. You declare a field, and the type inside it picks the widget.

struct Settings {
    core::Field<ui::Slider<>> volume{{.value = 0.6}};   // a slider
    core::Field<ui::Checkbox> mute{{.label = "Mute"}};  // a checkbox
    core::Field<std::string> status{"Ready"};           // read-only text
};

When the user moves the slider, volume changes and everything that watches it runs. When your code changes volume, the slider moves. There is no second copy of the value to keep in step.

New to fields? Read the model and views first. Every widget below runs live in the widget gallery, in your browser.

The families

Controls

Buttons, checkboxes, sliders, text fields, choices, pickers, labels.

Controls
Layout

Rows and columns, splits, groups, sections, scroll areas, tabs.

Layout
Data views

Lists, tables, trees and node boards.

Data views
Text and code

Long documents, code editors, find and replace, completion.

Text and code
Markdown and rich text

Headings, lists and bold text, read from and written to Markdown.

Markdown and rich text
Plot and canvas

Scientific plots, and your own drawing.

Plot and canvas
Menus and dialogs

Menu bars, context menus, dialogs, popovers, tooltips, file dialogs.

Menus and dialogs
Docking

Panels the user rearranges, floats and closes.

Docking
Drag and drop

Typed values dragged from one widget to another.

Drag and drop

Which type gives which widget

Field type

Widget

Page

bool

checkbox

Checkbox

ui::Checkbox

checkbox with a label

Checkbox

ui::Button

button, or a toggle with .checked

Button

ui::Slider<T>

slider over a range

Slider

ui::SpinBox<T>

number with steppers

Spin box

ui::TextField<>

one line of text

Text field

ui::Password<>

masked text

Text field

ui::TextArea<>

several lines of text

Text area

ui::ComboBox

text with suggestions

Combo box

any scoped enum

dropdown

Choices

ui::Radio<E>

radio buttons over an enum

Choices

ui::RadioGroup

radio buttons over strings

Choices

ui::Choice

dropdown over strings known at run time

Choices

core::Color

color picker

Color

std::chrono::year_month_day

date picker

Date and time

ui::TimeOfDay

time of day

Date and time

std::string, numbers

read-only text

Label

ui::Label<>

read-only text, a heading, wrapped text

Label

ui::Link

a link that opens a URL

Link

ui::ProgressBar

progress

Progress bar

ui::Picture

an image

Picture

ui::Expander

the header of a folding section

Groups and sections

ui::TabBar<>

tabs

Tabs and pages

ui::Menu

a menu title, and its menu

Menu

ui::ContextMenu

a right-click menu

Context menu

ui::Dialog

a modal dialog

Dialog

ui::Popup

a popover that holds widgets

Popover

ui::DockLayout

a dock of panels

Docking

Collections are not fields: a core::List<T> is shown by a list or a table, and a tree source by a tree. A text::Document is shown by a text view or an editor.

Widgets match on concepts, not on exact types. Your own string type works in a Label<> if it behaves like a string. Any scoped enum gets a dropdown, without registering it.