app: Create an application

View source: R/app.R

appR Documentation

Create an application

Description

Create an application

Usage

app(
  ...,
  bindings = list(),
  actions = list(),
  title = NULL,
  mouse = TRUE,
  stylesheet = NULL,
  theme = "default",
  debug = FALSE,
  reduce_motion = NULL
)

Arguments

...

Widgets to show, plus optional on() event handlers and bind() key bindings.

bindings

A list of bind() key bindings.

actions

A named list of action functions ⁠function(app)⁠ that bindings can refer to by name.

title

Optional title.

mouse

Enable mouse input (clicks, wheel, hover)?

stylesheet

A stylesheet(), stylesheet text, a file path, or a list of them.

theme

A termr_theme() or a built-in theme name ("default", "dark", "light").

debug

Bind F12 to a debug overlay (focused and hovered widget, last event, repaint statistics)?

reduce_motion

Turn decorative animation off? NULL follows motion_reduced().

Value

An App. Start it with run().

Built-in bindings: tab / shift+tab move focus, ctrl+c quits.

Examples

hello <- app(
  vertical(
    label("What is your name?"),
    input(id = "name"),
    button("Say hello", id = "hello"),
    label("", id = "output")
  ),
  on("button.pressed", "#hello", function(event, app) {
    name <- app$query_one("#name")$value
    app$query_one("#output")$update(paste("Hello", name))
  }),
  bind("escape", "quit")
)
if (interactive()) run(hello)

termr documentation built on Oct. 21, 2026, 5:13 p.m.