Expand description
Built-in widgets. Platform-free: each is an
Element with typed props, events and
accessibility defaults. Backends decide how they look.
Structs§
- Button
- Checkbox
- Column
- Vertical flex container.
new()returns aContainer: chain its methods, and the style setters ofElementBuilder. - Container
- A layout host: flexbox (column by default) or grid.
- Document
Tab - A tab of
DocumentTabs: its title, and the value choosing it gives the tabs’ selection. - Document
Tabs - Tabs for the documents the app has open, as a browser’s or a terminal’s: the platform’s own (in the title bar on macOS, as Safari’s and Xcode’s, and on Windows; libadwaita’s tab bar on GNOME, a tab bar on KDE). The tabs have no pages: the app shows the chosen document itself, in one place, as a terminal draws its sessions on one surface.
- File
Icon - A file’s or folder’s own icon, as the platform’s file manager shows
it: an app’s own, a folder’s custom one, a document’s by its type (the
icon theme’s on Linux). It’s a square as big as the platform’s small
icons (16 points) unless
icon_sizesays otherwise. Withthumbnail, a preview of what’s in the file (a picture’s, a document’s first page) where the platform makes one. The file is read when it’s set. Its label is its accessible name; without one it’s decorative, as it usually sits beside the file’s name. - GpuSurface
- A surface the app draws on with its own GPU API (wgpu, Vulkan, Metal,
Direct3D), at its own pace and on its own thread, as it would draw on a
window of its own: an
NSViewbacked by aCAMetalLayeron AppKit. It has no natural size; the layout sizes it. - Grid
- Grid container.
new()returns aContainer: chain its methods (columns,rows), and the style setters ofElementBuilder. - Group
- A box around related content, as the platform groups it: an
NSBox(its heading inside, at the top), libadwaita’s card under a heading, a Fluent card under a heading on Windows, aQQC2.GroupBox. The heading is optional; it names the group to assistive technology. - Icon
- An icon from the platform’s own set, by its name there: an SF Symbol
on macOS, a themed icon’s name on Linux (Adwaita’s symbolic ones on
GNOME, Breeze’s on KDE), a Segoe Fluent Icons glyph on Windows. Names
differ, so pick one per platform with
platform!. Symbolic icons are drawn in the colour the platform gives icons, which follows dark mode. It’s as large as the platform makes icons unlessicon_sizesays otherwise. Its label is its accessible name; without one it’s decorative. - Image
- A picture, in the platform’s image view: from a file, or from pixels
in memory. It’s as large as the image (in points: pixels over their
scale) unless the layout sizes it; then
fitsays how it fills the frame, or the platform does as it does by default. Its label is its accessible name; without one it’s decorative. - Menu
Button - A button that opens a menu of actions, as the platform makes one: a
pull-down
NSPopUpButton, agtk::MenuButton, aDropDownButton, aQQC2.Buttonthat opens aQQC2.Menu. Each draws its own arrow. The menu is built as a context menu is, and an item’son_selectruns when it’s chosen. It has no click of its own: clicking opens the menu. - Number
Input - A field for a whole number, with buttons that step it up and down, as
the platform’s spin box shows it. Its label is its accessible name; show
one beside it with a
Text. Typing reports the number when the edit is done (Return, or leaving the field), as each platform commits one. Whole numbers in ani32, because Qt’s spin box holds anint. - Password
Input - Single-line entry of a password: the platform’s password field, which hides the text as the platform does (bullets, and a button to show it where the platform has one) and never reads it out.
- Progress
- A progress bar, as the platform draws one: how far along a task is, from
0 to 1, or, until a value is given (or while
indeterminate), an animated bar for work of unknown length. Its label is its accessible name. - Radio
Group - Radio buttons, one for each of its options, to choose one from:
NSButtons of the radio type,RadioButtons,gtk::CheckButtons in a group,QQC2.RadioButtons. Down a column, as each platform stacks them. Its label is its accessible name; it isn’t drawn, so put aTextabove it. - Row
- Horizontal flex container.
new()returns aContainer: chain its methods, and the style setters ofElementBuilder. - Scroll
View - A native scroll container. Its children go into a content box that keeps its natural size, so it can be larger than the scroll view.
- Search
Input - Single-line entry of search text: the platform’s search field, with its
search icon and clear button.
on_searchis called when the platform asks for a search, as its own apps search. - Select
- A pop-up menu of text options to choose one from:
NSPopUpButton,ComboBox,gtk::DropDown,QQC2.ComboBox. Its label is its accessible name; like a text field’s, it isn’t drawn, so put aTextnext to it. - Separator
- A line between groups of content, as the platform draws one: a
separator
NSBox,gtk::Separator,Kirigami.Separator, and on WinUI, which has no separator control, aBorderin the divider brush, as Fluent apps draw one. Horizontal unless told otherwise, as thick as the platform makes it; its length is the layout’s, so it spans a column (or a row, vertical) that stretches its children, as they do by default. - Sidebar
- The sidebar of the window it’s declared in: the list down its leading side that picks what the window shows, as in macOS’s System Settings and GNOME’s Settings (a source list on macOS, libadwaita’s navigation split view on GTK, a NavigationView’s pane on Windows, a first column of Kirigami’s page row on KDE). Declare it anywhere in the window’s content; it stays while it does.
- Sidebar
Item - An item of a
Sidebar: a title, the value choosing it gives the sidebar’s selection, and optionally an icon, a subtitle and a context menu. - Sidebar
Section - A group of a
Sidebar’s items, under a heading. - Slider
- A slider: a number in a range, as the platform’s slider shows it, horizontal or vertical. Its label is its accessible name. What its step does is the platform’s: AppKit shows it as tick marks the knob stops at, WinUI and GTK snap the user’s moves to it, and Qt moves by it from the keyboard.
- Spinner
- A spinner, as the platform draws one, for work of unknown length: a
spinning
NSProgressIndicator,gtk::Spinner,ProgressRing,QQC2.BusyIndicator. It spins while running (from the start, unless told otherwise), and shows nothing while stopped, keeping its place. Its label is its accessible name. - Switch
- On/off switch. Most platforms draw no caption; the label is its accessible name.
- Tab
- A page of
Tabs: its title, the value picking it gives the tabs’ selection, and what it shows, in a column. - Tabs
- Pages, one shown at a time, with a tab for each to pick it: the platform’s own tab view (an NSTabView on macOS, a notebook on GTK, a selector bar over its pages on Windows, a tab bar on KDE). It’s for a fixed set of views, as in a settings window, not documents the user opens and closes.
- Text
- Static or reactive text.
- Text
Area - Text over many lines: the platform’s text area, whose lines wrap to its
width and where Return starts a new line. It’s as tall as
linesof the platform’s text, and scrolls past them. - Text
Input - Single-line text entry.
- Toggle
Button - A button that stays pressed until it’s clicked again, as the platform
makes one: an
NSButtonthat pushes on and off, agtk::ToggleButton, aToggleButton, a checkableQQC2.Button. Its caption, icon and style are aButton’s; whether it’s pressed ischecked, as a checkbox’s. - Toolbar
- Items for the toolbar of the window it’s declared in: the bar across the top that shows the window’s title (the unified toolbar on macOS, GTK’s header bar, a command bar on WinUI, the page toolbar on KDE). Declare it anywhere in the window’s content; its items stay while it does.
- Window
- A window the app opens while it runs: shown while
openis true, with its content built when it opens and disposed when it closes. Declare it anywhere in the tree, next to the state that opens it; it closes with the scope that declared it, and belongs to the window it’s declared in.
Traits§
- Document
Tabs Children - What
DocumentTabstake as children:DocumentTabs, and tuples,Vecs andOptions of them. - Sidebar
Entries - What a
Sidebartakes as children:SidebarItems,SidebarSections, and tuples,Vecs andOptions of them. - Sidebar
Items - What a
SidebarSectiontakes as children:SidebarItems, and tuples,Vecs andOptions of them. - Tabs
Children - What
Tabstake as children:Tabs, and tuples,Vecs andOptions of them.