- `Title:` [[+ 2021-02-22 Carson Sievert Custom theming in Shiny and R Markdown with bslib and thematic RStudio]] - `Type:` [[🌲️/+]] - `Tags:` [[DevLog/r]] - [[shiny]] - [[CSS]] - `URL:` <https://youtu.be/zAqoLCQ83Ns> - `Channel/Host:` [[RStudio]] - `Reference:` - `Publish Date:` 2021-02-20 - `Reviewed Date:` [[2021-02-22]] --- <center> <iframe width="560" height="315" src="https://www.youtube.com/embed/zAqoLCQ83Ns" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> </center> --- - [1:42](https://youtu.be/zAqoLCQ83Ns?t=102) [[#^b764ea]] - [2:24](https://youtu.be/zAqoLCQ83Ns?t=144) `bslib::bs_theme_preview(theme)` for examples - [2:45](https://youtu.be/zAqoLCQ83Ns?t=165) `thematic::thematic_shiny()` for carrying styling over to the plots ```r library(bslib) ui <- fluidPage( theme = bslib::bs_theme( version = 4, bg = "#282828", fg = "#ebdbb2", primary = "#fabd24", secondary = "#689d6a" ), ``` ^b764ea ```r # # This is a Shiny web application. You can run the application by clicking # the 'Run App' button above. # # Find out more about building applications with Shiny here: # # http://shiny.rstudio.com/ # library(shiny) # Define UI for application that draws a histogram library(bslib) library(thematic) ui <- fluidPage( theme = bslib::bs_theme( version = 4, bg = "#282828", fg = "#ebdbb2", primary = "#fabd24", secondary = "#689d6a", base_font = "Norse" ), thematic::thematic_shiny(), # Application title titlePanel("Old Faithful Geyser Data"), # Sidebar with a slider input for number of bins sidebarLayout( sidebarPanel( sliderInput("bins", "Number of bins:", min = 1, max = 50, value = 30) ), # Show a plot of the generated distribution mainPanel( plotOutput("distPlot") ) ) ) # Define server logic required to draw a histogram server <- function(input, output) { output$distPlot <- renderPlot({ # generate bins based on input$bins from ui.R x <- faithful[, 2] bins <- seq(min(x), max(x), length.out = input$bins + 1) # draw the histogram with the specified number of bins hist(x, breaks = bins, col = 'darkgray', border = 'white') }) } # Run the application shinyApp(ui = ui, server = server) ```