The L2 default-layout UI bundle for a ggpaintr formula: owns its own
.ptr-app theme scope + asset bundle (nothing else to remember) and is
namespaced by id. Pair with the single public ptr_server(). For a
hand-composed L3 layout, use the bare ptr_ui_* pieces instead and pair
them with the same ptr_server().
Usage
ptr_ui(
formula,
id = NULL,
envir = parent.frame(),
ui_text = NULL,
expr_check = TRUE,
css = NULL,
shared = NULL
)Arguments
- formula
Either a single character scalar containing a ggplot expression with
ggpaintrplaceholders, or an unquoted ggplot expression supplied directly (the primary form). Captured withrlang::enexpr()exactly asptr_app()/ptr_server(), so a formula stored in a variable viarlang::expr()can be passed by its bare symbol (f <- rlang::expr(ggplot(...)); ptr_ui(f, "id")) or spliced with!!(ptr_ui(!!f, "id")); a subscripted/extracted element resolves bare too (ptr_ui(plots[[1]], "id"),holder$body). Seeptr_app()for the full contract (symbol resolution, wrapper unwrap, native-pipe caveat).- id
Optional module id; the namespace prefix for inputs and outputs. Defaults to
NULL(identity namespace, single-instance use).- envir
Environment used to resolve a
formulapassed as a bare symbol and any local data objects. Defaults to the calling frame.- ui_text
Optional named list of copy overrides; see
ptr_ui_text()for the full schema and current defaults.- expr_check
Controls formula-level
ppExprvalidation:TRUE(default) applies the built-in denylist + AST walker;FALSEdisables formula-level validation; alistwithdeny_list/allow_listentries customises the formula-level policy. Runtime-typedppExprinput is always screened against the built-in denylist regardless. See the safety chapter of the ggpaintr book (development-version docs): https://willju-wangqian.github.io/ggpaintr-book/safety.html.- css
Optional character vector of paths to additional CSS files; linked after
ggpaintr's bundled stylesheet so its rules win. Seeptr_app()for the full semantics. Defaults toNULL.Optional coordinator object from
ptr_shared()for the multi-instance embedding. Forwarded verbatim toptr_ui_controls(). WhenNULL(the single-instance default) the inline "Shared controls" section renders everyshared = "..."placeholder informula. When aptr_shared_specis supplied, its cross-formula keys (shared$panel_keys) are excluded here because they belong to the one standaloneptr_shared_panel(); only this formula's formula-local shared keys render inline. Defaults toNULL.
See also
ptr_server(), ptr_css() for the css = argument and
themable CSS custom properties.
Examples
# Expression form (primary): an unquoted ggplot call.
ui <- ptr_ui(ggplot(mtcars, aes(x = ppVar, y = ppVar)) + geom_point(), "plot1")
# Stored in a variable, spliced with `!!` (paired with ptr_server(!!f, "plot1")).
f <- rlang::expr(ggplot(mtcars, aes(x = ppVar, y = ppVar)) + geom_point())
ui2 <- ptr_ui(!!f, "plot1")
# String form (fallback): equivalent.
ui3 <- ptr_ui("ggplot(mtcars, aes(x = ppVar, y = ppVar)) + geom_point()", "plot1")
