Sends a custom message that sets/removes data-shad-theme and toggles
.dark + data-bs-theme on document.documentElement.
Usage
update_shad_theme(
preset = NULL,
dark = NULL,
theme = NULL,
session = shiny::getDefaultReactiveDomain()
)Arguments
- preset
A preset name,
"default"to clear the preset, orNULLto leave it unchanged.- dark
TRUE/FALSEto set dark mode, orNULLto leave unchanged.- theme
An optional custom
shad_theme()to apply live (its tokens are written to a managed<style>element); passNAto remove a previously applied custom theme.- session
The Shiny session.
See also
Other shadshiny page & theming:
page_shad(),
shad_theme_preset()
Examples
if (interactive()) {
ui <- page_shad(
shad_select("preset", "Theme", selected = "slate",
choices = c("slate", "zinc", "mauve", "blue", "green")),
shad_switch("dark", "Dark mode")
)
server <- function(input, output, session) {
shiny::observe(update_shad_theme(preset = input$preset, dark = input$dark))
}
shiny::shinyApp(ui, server)
}