Skip to contents

Sends a one-way command from the Shiny server that sets a live browser-side property on the element identified by DOM id.

Usage

wa_set_property(
  id,
  property,
  value,
  session = shiny::getDefaultReactiveDomain()
)

Arguments

id

DOM id of the target browser element.

property

Scalar property name to assign on the target element.

value

Value to assign. This should be serializable through Shiny's custom-message transport. In practice, prefer JSON-like values such as strings, numbers, logicals, NULL, vectors/lists of scalars, and named lists that map cleanly to browser objects. Do not expect R functions, language objects, or HTML tags to serialize into useful browser-side values.

session

Shiny session object. Defaults to the current reactive domain.

Value

Invisibly returns NULL.

Details

wa_set_property() is a narrow package-level escape hatch for advanced cases where a Web Awesome component property needs to be updated from server logic but is not covered by a generated update helper. It does not validate whether the requested property exists for the targeted component.

This helper is complementary to generated component bindings and update helpers. It is not part of upstream component coverage and does not expand the generated per-component API surface.

On the server side, wa_set_property() validates only its R helper inputs, such as the target id, property name, and session. It does not validate whether the requested property exists on the browser-side element.

In the browser runtime, the command layer validates that the target DOM id resolves to an element and that a property name was supplied, then assigns the value directly. Command-layer warnings are controlled by the package warning registry, especially the command_layer key. For option details, see the Package Options article.

Examples

# \donttest{
library(shiny)
library(shiny.webawesome)

ui <- webawesomePage(
  wa_button("Open dialog", id = "open_dialog"),
  wa_dialog("Dialog body", id = "dialog")
)

server <- function(input, output, session) {
  observeEvent(input$open_dialog, {
    wa_set_property("dialog", "open", TRUE, session = session)
  })
}

app <- shinyApp(ui, server)
stopifnot(inherits(app, "shiny.appobj"))

# Run `app` interactively to launch this example application.
# }