### Install shinythemes package Source: https://rstudio.github.io/shinythemes Install the shinythemes package from CRAN. Requires Shiny 0.11 or later. ```r install.packages("shinythemes") ``` -------------------------------- ### Add themeSelector() to UI for live theme switching Source: https://rstudio.github.io/shinythemes Add shinythemes::themeSelector() to the UI to get a select box for choosing themes without reloading. Intended for development only; replace with a fixed theme argument once chosen. ```r shinyApp( ui = fluidPage( shinythemes::themeSelector(), # <--- Add this somewhere in the UI sidebarPanel( textInput("txt", "Text input:", "text here"), sliderInput("slider", "Slider input:", 1, 100, 30), actionButton("action", "Button"), actionButton("action2", "Button2", class = "btn-primary") ), mainPanel( tabsetPanel( tabPanel("Tab 1"), tabPanel("Tab 2") ) ) ), server = function(input, output) {} ) ``` -------------------------------- ### Directory structure for custom theme in www/ Source: https://rstudio.github.io/shinythemes Place a custom CSS file (e.g., mytheme.css) in the www/ subdirectory of the app. Files there are automatically served to the app. ```text myapp |-- server.R |-- ui.R |-- www/ |-- mytheme.css ``` -------------------------------- ### Reference custom theme in ui.R Source: https://rstudio.github.io/shinythemes In ui.R, set the theme argument to the filename of the custom CSS file (e.g., "mytheme.css"). The file must be in the www/ directory. ```r fluidPage( theme = "mytheme.css", ... ) ``` -------------------------------- ### Use shinytheme() in single-file app.R Source: https://rstudio.github.io/shinythemes For a single-file app, pass shinytheme("united") to the theme argument of fluidPage inside shinyApp(). The server function is defined inline. ```r ## app.R ## library(shinythemes) shinyApp( ui = fluidPage(theme = shinytheme("united"), ... ), server = function(input, output) { } ) ``` -------------------------------- ### Use shinytheme() in ui.R with fluidPage Source: https://rstudio.github.io/shinythemes In ui.R, pass shinytheme("cerulean") to the theme argument of fluidPage. The library(shinythemes) call is required. ```r ## ui.R ## library(shinythemes) fluidPage(theme = shinytheme("cerulean"), ... ) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.