tui select for viewers
Add a radio list of items, or a checkbox list with --multi.
Command Type
built-in
Signature
> tui select {flags} (items)
Flags
--display, -d {oneof<string, closure(any)>}: Column or closure that produces each item's label.--index, -i: Select item indexes instead of items.--id {string}: Widget id.--focus: Start with this widget focused.--data {any}: Data for this widget alone, instead of the outer pipeline's.--from {string}: Id of the table, tree, or select whose highlighted row drives this widget.--on-select {closure(any)}: Hook run when the highlighted row changes; receives the state record.--multi, -m: Space toggles rows; the selection is the checked rows.
Parameters
items: Items to choose from. Defaults to the widget's data rows.
Input/output types:
| input | output |
|---|---|
| nothing | tui |
| tui | tui |
| any | tui |
Examples
Pick one of three options
> tui select [small medium large] | tui debug --keys [down enter] | get selectedCheck several files by name
> ls | tui select --multi --display name | tui run | get selected.nameNotes
Items come from the list argument, from --data, or from the pipeline. Up/Down move, Space checks (with --multi), Enter submits the chosen item(s); --index submits positions instead.
--display picks the text shown for each item: a column name for records, or a closure over the item. The original item is what gets selected, as with input list --display.