Send a message to the browser to change the Liquid Glass preset, accent
color, intensity, or content-tint behavior without reloading the page.
Requires a page that used glass_theme() (so shiny-glass.js is loaded).
Usage
update_glass_theme(
session,
preset = NULL,
tint = NULL,
primary = NULL,
intensity = NULL,
material = NULL,
plot_surface = NULL,
ambient_motion = NULL,
scene = NULL,
flatten = NULL,
tokens = NULL
)Arguments
- session
A Shiny session object (usually the
sessionargument of the server function).- preset
Optional.
"light","dark", or"auto".- tint
Optional logical. Enable or disable content-aware ambient tint.
- primary
Optional accent color (hex like
"#AF52DE"orrgb()).- intensity
Optional numeric in \([0, 1]\): Ultra Clear (
0) to Tinted (1).- material
Optional
"regular"or"clear".- plot_surface
Optional
"clear"or"opaque".- ambient_motion
Optional logical.
- scene
Optional scene id from
glass_scenes().- flatten
Optional logical. See
glass_flatten().- tokens
Optional named list of CSS token overrides (see
glass_add_tokens()). Applied live via CSS variables.
Details
primary updates CSS variables (--bs-primary, --bs-primary-rgb,
--glass-primary) so buttons, checks, and other accent surfaces follow the
new color. Sass-baked one-off colors may not all switch until a full reload.
intensity updates fill/blur along the Ultra Clear to Tinted spectrum
(see glass_intensity_slider()).
Examples
if (interactive()) {
library(shiny)
library(shinyglass)
ui <- fluidPage(
theme = glass_theme(),
glass_theme_toggle(),
selectInput("accent", "Accent", c("#007AFF", "#AF52DE", "#FF9500"))
)
server <- function(input, output, session) {
observe_glass_theme_toggle(input, session)
observeEvent(input$accent, {
update_glass_theme(session, primary = input$accent)
}, ignoreInit = TRUE)
}
shinyApp(ui, server)
}