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).
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).
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)
}