input_dark_mode: Dark mode input control

View source: R/input-dark-mode.R

input_dark_modeR Documentation

Dark mode input control



Creates a button that toggles between dark and light modes, specifically for toggling between light and dark Bootstrap color modes – a new feature added in Bootstrap 5.3.


input_dark_mode(..., id = NULL, mode = NULL)

toggle_dark_mode(mode = NULL, ..., session = get_current_session())



Additional attributes to be passed to the input control UI, such as class, style, etc.

In toggle_dark_mode(), the ... are included for future extensibility and are currently ignored.


An optional input id, required to reactively read the current color mode.


The initial mode of the dark mode switch. By default or when set to NULL, the user's system settings for preferred color scheme will be used. Otherwise, set to "light" or "dark" to force a particular initial mode.


A Shiny session object (the default should almost always be used).


Returns a UI element for a dark mode switch input control. The server value received for the input corresponding to id will be a string value with the current color mode ("light" or "dark").


  • input_dark_mode(): Create a dark mode switch input control

  • toggle_dark_mode(): Programmatically toggle or set the current light or dark color mode.

See Also

Other input controls: input_switch()

bslib documentation built on May 29, 2024, 6:31 a.m.