Nushell
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
  • 한국어
GitHub
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
  • 한국어
GitHub
  • Categories

    • Bits
    • Bytes
    • Chart
    • Conversions
    • Core
    • Database
    • Dataframe
    • Dataframe Or Lazyframe
    • Date
    • Debug
    • Default
    • Env
    • Experimental
    • Expression
    • Filesystem
    • Filters
    • Formats
    • Generators
    • Hash
    • History
    • Lazyframe
    • Math
    • Misc
    • Network
    • Path
    • Platform
    • Plugin
    • Prompt
    • Random
    • Removed
    • Shells
    • Strings
    • System
    • Viewers

tui button for viewers

Add a button that runs a hook, or submits its label, when activated.

Command Type

built-in

Signature

> tui button {flags} (label) (hook)

Flags

  • --id {string}: Widget id.
  • --focus: Start with this widget focused.

Parameters

  • label: Button text.
  • hook: Closure run with the state record when activated.

Input/output types:

inputoutput
nothingtui
tuitui
anytui

Examples

A yes/no confirm

> tui label "Delete everything?" | tui button Yes | tui button No | tui debug --keys [tab enter] | get selected

A button that saves the text box and quits

> tui textbox --id name | tui button Save {|s| $s.values.name | save name.txt; {action: quit} } | tui run

Notes

Tab to the button and press Enter or Space, or click it. With a hook closure the button behaves like tui bind: the closure receives the state record and may return a new data list or {action: submit|quit, ...}. Without one, activating submits the label, so tui button Yes | tui button No is a confirm dialog.