The public TUI element API: the generators authors use to build a tree of terminal-native nodes
from a Fulcro component's render — vbox, hbox, box, text, input, button, line,
viewport, modal, picker — plus focused? (highlight the focused node). State changes use
Fulcro's own com.fulcrologic.fulcro.components/transact!; this namespace adds no transact.
A node is a plain map keyed by the com.fulcrologic.fulcro.tui.engine vocabulary (::engine/tag,
::engine/attrs, ::engine/children); prefer these generators over building the maps by hand.
The engine (com.fulcrologic.fulcro.tui.engine) lays the tree out and paints it; this namespace
depends on the engine for that node vocabulary and node?/*current-focus*.
This is JVM/babashka only (plain .clj).
The public TUI element API: the generators authors use to build a tree of terminal-native *nodes* from a Fulcro component's render — `vbox`, `hbox`, `box`, `text`, `input`, `button`, `line`, `viewport`, `modal`, `picker` — plus `focused?` (highlight the focused node). State changes use Fulcro's own `com.fulcrologic.fulcro.components/transact!`; this namespace adds no transact. A node is a plain map keyed by the `com.fulcrologic.fulcro.tui.engine` vocabulary (`::engine/tag`, `::engine/attrs`, `::engine/children`); prefer these generators over building the maps by hand. The engine (`com.fulcrologic.fulcro.tui.engine`) lays the tree out and paints it; this namespace depends on the engine for that node vocabulary and `node?`/`*current-focus*`. This is JVM/babashka only (plain `.clj`).
(box & args)Returns a :box node: a single styling/padding/border container around children. An optional
leading attribute map sets layout/style attributes.
Returns a `:box` node: a single styling/padding/border container around `children`. An optional leading attribute map sets layout/style attributes.
(button & args)Returns a :button node rendering children as its label. An optional leading attribute map sets
:id, :on-activate, and style attributes.
Returns a `:button` node rendering `children` as its label. An optional leading attribute map sets `:id`, `:on-activate`, and style attributes.
(element tag args)Returns a TUI node with the given tag built from args. If the first of args is a map it is
used as the node's attributes (otherwise attributes default to {}); the remaining args become
the node's children (flattened, with nils removed). Prefer the named generators (vbox, etc.)
over calling this directly.
Returns a TUI node with the given `tag` built from `args`. If the first of `args` is a map it is
used as the node's attributes (otherwise attributes default to `{}`); the remaining `args` become
the node's children (flattened, with `nil`s removed). Prefer the named generators (`vbox`, etc.)
over calling this directly.(flatten-children children)Returns a vector of children with nested sequential collections flattened and nils removed.
Nodes, strings, and numbers are retained as-is, in order. This lets callers splice seqs of
children (e.g. from map) directly into an element's argument list.
Returns a vector of `children` with nested sequential collections flattened and `nil`s removed. Nodes, strings, and numbers are retained as-is, in order. This lets callers splice seqs of children (e.g. from `map`) directly into an element's argument list.
(focused? id)Returns true if id is the id of the node that currently has focus (per the
dynamically bound engine/*current-focus*).
Returns true if `id` is the id of the node that currently has focus (per the dynamically bound `engine/*current-focus*`).
(hbox & args)Returns an :hbox node that stacks children horizontally. An optional leading attribute map
sets layout/style attributes for the container.
Returns an `:hbox` node that stacks `children` horizontally. An optional leading attribute map sets layout/style attributes for the container.
(input attrs)Returns an :input leaf node from the given attrs map. Inputs are controlled: :value (and
optionally :caret) come from props, and :on-change receives proposed edits.
Returns an `:input` leaf node from the given `attrs` map. Inputs are controlled: `:value` (and optionally `:caret`) come from props, and `:on-change` receives proposed edits.
(line & args)Returns a :line leaf node (a rule). An optional leading attribute map sets orientation/style.
Returns a `:line` leaf node (a rule). An optional leading attribute map sets orientation/style.
(modal & args)Returns a :modal overlay node stacking children vertically inside a window that the driver
floats over the rest of the UI (compositing it on top and trapping focus/keyboard input to it).
An optional leading attribute map sets:
:id - (recommended) identity for focus/queries.:open? - the overlay is active (composited + focus-trapped) only when truthy. When falsy
the modal renders nothing.:width/:height - the window size in cells (a number, or a [:fraction f] of the screen);
defaults to the modal's intrinsic content size when omitted.:align - position on screen, one of :center (default), :start, :end.:border? - draw a border (default true).:title - a string painted onto the top border.:on-dismiss- a zero-arg handler invoked when Escape is pressed while the modal is active.Lifecycle (toggling :open?, recording any selection) is the application's responsibility via its
own state/mutations — this node owns no state.
Returns a `:modal` overlay node stacking `children` vertically inside a window that the driver
floats over the rest of the UI (compositing it on top and trapping focus/keyboard input to it).
An optional leading attribute map sets:
* `:id` - (recommended) identity for focus/queries.
* `:open?` - the overlay is active (composited + focus-trapped) only when truthy. When falsy
the modal renders nothing.
* `:width`/`:height` - the window size in cells (a number, or a `[:fraction f]` of the screen);
defaults to the modal's intrinsic content size when omitted.
* `:align` - position on screen, one of `:center` (default), `:start`, `:end`.
* `:border?` - draw a border (default `true`).
* `:title` - a string painted onto the top border.
* `:on-dismiss`- a zero-arg handler invoked when Escape is pressed while the modal is active.
Lifecycle (toggling `:open?`, recording any selection) is the application's responsibility via its
own state/mutations — this node owns no state.(picker {:keys [id open? title width height options on-select on-cancel]})Returns a :modal overlay presenting options as a scrollable list of selectable rows — a list
picker. Each row is a focusable button, so the focused row IS the highlighted choice: the focus
ring moves the highlight (Up/Down/Tab), the enclosing :viewport auto-scrolls to keep it visible
(PageUp/PageDown page it), Enter selects, and Escape cancels. State and selection handling are the
application's responsibility — this is a pure composition of existing nodes. opts:
:id - (required) base keyword for the modal and per-row focus ids.:open? - the picker is shown only when truthy.:title - optional title painted on the modal border.:width/:height - window size in cells (default 40 x 12).:options - a vector of {:value :label} maps (:value a keyword/string/symbol, :label
the displayed text).:on-select - one-arg handler called with a row's :value when its row is activated (Enter).:on-cancel - zero-arg handler called on Escape (wired to the modal's :on-dismiss).Returns a `:modal` overlay presenting `options` as a scrollable list of selectable rows — a list
picker. Each row is a focusable button, so the focused row IS the highlighted choice: the focus
ring moves the highlight (Up/Down/Tab), the enclosing `:viewport` auto-scrolls to keep it visible
(PageUp/PageDown page it), Enter selects, and Escape cancels. State and selection handling are the
application's responsibility — this is a pure composition of existing nodes. `opts`:
* `:id` - (required) base keyword for the modal and per-row focus ids.
* `:open?` - the picker is shown only when truthy.
* `:title` - optional title painted on the modal border.
* `:width`/`:height` - window size in cells (default 40 x 12).
* `:options` - a vector of `{:value :label}` maps (`:value` a keyword/string/symbol, `:label`
the displayed text).
* `:on-select` - one-arg handler called with a row's `:value` when its row is activated (Enter).
* `:on-cancel` - zero-arg handler called on Escape (wired to the modal's `:on-dismiss`).(text & args)Returns a :text node rendering its string/number children as text. An optional leading
attribute map sets style attributes (e.g. :color, :highlight).
Returns a `:text` node rendering its string/number `children` as text. An optional leading attribute map sets style attributes (e.g. `:color`, `:highlight`).
(vbox & args)Returns a :vbox node that stacks children vertically. An optional leading attribute map sets
layout/style attributes for the container.
Returns a `:vbox` node that stacks `children` vertically. An optional leading attribute map sets layout/style attributes for the container.
(viewport & args)Returns a :viewport node: a fixed-size container whose (potentially larger) children scroll
within its bounds. An optional leading attribute map sets size and :id (for scroll state).
Returns a `:viewport` node: a fixed-size container whose (potentially larger) `children` scroll within its bounds. An optional leading attribute map sets size and `:id` (for scroll state).
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |