6. Widget tour

May 15, 2026 · View on GitHub

A reference table of every widget shipped in widgets/, with a one-liner on what it does, the Builder method that creates it, and a pointer to the detailed reference page.

This chapter is a catalog — skim it, mark what you need. The next chapter takes containers seriously; the chapter after looks at writing your own widget.

Containers — they hold other widgets

Builder methodWidgetOne-linerReference
Box(id, title)BoxBordered container with optional title.box
Card(...)CardBox with extra header style for grouped content.
Collapsible(id, title, expanded)CollapsibleHeader you can toggle to reveal/hide one child.collapsible
Dialog(id, title)DialogSingle-child container intended for popup layers.dialog
HFlex(id, alignment, spacing)FlexLinear layout, horizontal.flex
VFlex(id, alignment, spacing)FlexLinear layout, vertical.flex
Grid(id, rows, cols, lines)GridCell-spanning table layout.grid
Form(id, title, data)FormAuto-generated form bound to a struct.form
Group(id, title, name, horizontal, spacing)FormGroupLabeled cluster of form controls.form-group
Switcher(id, connect)SwitcherShows one child at a time; Select(i) swaps.switcher
Tabs(id, names...)TabsTab strip; usually paired with a Switcher.tabs
Viewport(id, title)ViewportScrollable wrapper for oversized content.viewport

Input — they accept user data

Builder methodWidgetOne-linerReference
Button(id, text)ButtonClickable button; fires EvtActivate.button
Checkbox(id, text, checked)CheckboxToggleable boolean; fires EvtChange (bool).checkbox
Combo(id, items...)ComboFree-text input with a suggestion list.
Editor(id)EditorMulti-line text editor (gap-buffer based).editor
Filter(id)FilterGeneric filter input wired to a list/table.
Input(id, params...)InputSingle-line text field.input
List(id, items...)ListScrollable selectable list.list
Select(id, args...)SelectDropdown selection.select
Tree(id)TreeExpandable hierarchy.tree
TreeFS(id, root, dirsOnly)TreeTree pre-bound to a filesystem path.
Typeahead(id, params...)TypeaheadInput + filtered suggestions.typeahead

Display — they show data

Builder methodWidgetOne-linerReference
Static(id, text)StaticPlain text label.static
Styled(id, text)StyledRich text with inline markup.styled
Text(id, content, follow, max)TextMulti-line scrollable text.text
Digits(id, text)DigitsBig ASCII-art digits, e.g. for clocks.digits
Breadcrumb(id)BreadcrumbPath-style segment indicator.
Table(id, provider, cellNav)TableTabular data. Drives off a TableProvider.table
HRule(style) / VRule(style)RuleSingle-line separator.rule
Spacer()Invisible flex child that swallows leftover space.

Animated — they tick

Builder methodWidgetOne-linerReference
Clock(id, interval, params...)ClockLive wall-clock display.
Marquee(id)MarqueeScrolling text.
Progress(id, horizontal)ProgressBar (determinate or indeterminate).progress
Scanner(id, width, charStyle)ScannerBack-and-forth scanning indicator.scanner
Shimmer(id)ShimmerSkeleton-style loading shimmer.
Sparkline(id)SparklineTiny inline trend chart.sparkline
Spinner(id, sequence)SpinnerAnimated loading glyph.spinner
Typewriter(id)TypewriterReveals text one character at a time.

Specialised

Builder methodWidgetOne-linerReference
BarChart(id)BarChartMulti-series stacked bars.
Canvas(id, pages, w, h)CanvasLow-level pixel buffer for custom drawings.canvas
Deck(id, render, itemHeight)DeckStack of items rendered by a callback.deck
Heatmap(id, rows, cols)HeatmapColoured cell grid for matrix data.heatmap
Terminal(id)TerminalEmbedded terminal emulator.
Tiles(id, render, tileW, tileH)TilesWrapping grid of fixed-size tiles.

Reading the reference pages

Each reference page in doc/reference/ follows the same shape:

  • One-paragraph description.
  • Constructor signature.
  • Public methods you'd call after Find / MustFind.
  • Events the widget dispatches, with the data types.
  • Style selectors and parts the theme can target.

Start there once you know which widget you want.

Patterns worth noting

A few cross-cutting patterns the table doesn't surface:

Setter widgets accept values.Update. Many widgets implement values.Setter[T] for some T. values.Update(ui, "tables", names) calls Set([]string) on a *List; values.Update(ui, "result", provider) calls Set(TableProvider) on a *Table. The values package is how you get data into a widget without first calling MustFind and casting yourself.

Tables eat anything. widgets.NewArrayTableProvider(cols, rows) covers the common case; for anything else, implement the three-method TableProvider interface (Columns, Length, Str(row, col)).

Tabs and Switcher are usually paired. Tabs renders the strip and fires EvtActivate with the tab index; Switcher flips children when you call .Select(i). The connect flag on Switcher shows/hides children via EvtShow/EvtHide rather than reparenting them, which keeps state intact across switches.

Custom (in widgets/custom.go) is the escape hatch for one-off visuals — you give it a render callback and skip writing a full widget type. Good for prototypes; promote to a real widget once you start copy-pasting it.

Next: Containers in depth