Skip to contents

Drop-in button group for switching the glass preset. Each button sets the preset on the client immediately (window.shinyglass.setPreset) and also has a 'shiny' input id so observe_glass_theme_toggle() can keep the server in sync (important on hosts that rewrite custom messages).

Usage

glass_theme_toggle(
  inputId = "glass_toggle",
  selected = c("auto", "light", "dark"),
  labels = c(light = "Light", dark = "Dark", auto = "Auto (OS)"),
  class = "glass-theme-toggle"
)

Arguments

inputId

Base id. Buttons are {inputId}_light, {inputId}_dark, and {inputId}_auto.

selected

Initially highlighted mode ("light", "dark", or "auto"). Cosmetic only; the page theme still comes from glass_theme().

labels

Named character vector for button labels. Names must be light, dark, and/or auto.

class

Extra CSS classes for the wrapper.

Value

An htmltools::tag() button group.

Examples

glass_theme_toggle(selected = "dark")
#> <div class="glass-theme-toggle" role="group" aria-label="Glass theme preset">
#>   <button aria-pressed="false" class="btn btn-default action-button btn-sm btn-secondary" data-glass-preset-mode="light" id="glass_toggle_light" type="button"><span class="action-label">Light</span></button>
#>   <button aria-pressed="true" class="btn btn-default action-button btn-sm btn-primary" data-glass-preset-mode="dark" id="glass_toggle_dark" type="button"><span class="action-label">Dark</span></button>
#>   <button aria-pressed="false" class="btn btn-default action-button btn-sm btn-secondary" data-glass-preset-mode="auto" id="glass_toggle_auto" type="button"><span class="action-label">Auto (OS)</span></button>
#> </div>