1

Could you help me change my theme using bslib package from RStudio?

I would like the top bar to be light green. Also, if possible, the created button (reset) had a blue background.

It is possible?

Executable code below:

library(shiny)
library(shinythemes)


ui <- shiny::navbarPage(theme = shinytheme("flatly"),collapsable = TRUE,
                        
                        
                        titlePanel(""),
                        
                        
                        sidebarLayout(
                          sidebarPanel(
                            sliderInput("bins",
                                        "Number of bins:",
                                        min = 1,
                                        max = 50,
                                        value = 30),
                            actionButton("reset", "Reset"),
                          ),
                          
                          
                          mainPanel(
                            plotOutput("distPlot")
                          )
                        )
)


server <- function(input, output) {
  
  output$distPlot <- renderPlot({
    
    x    <- faithful[, 2]
    bins <- seq(min(x), max(x), length.out = input$bins + 1)
    
    
    hist(x, breaks = bins, col = 'darkgray', border = 'white')
  })
}


shinyApp(ui = ui, server = server)
Antonio
  • 1,091
  • 7
  • 24
  • You can theme using CSS. Here is an answer describing how to style an actionButton: https://stackoverflow.com/questions/33620133/change-the-color-of-action-button-in-shiny – bs93 Sep 01 '21 at 01:49
  • if you want to use the `bslib` package, wouldn't you want to include the package in the shiny app? `library(bslib)` – Daniel_j_iii Jul 14 '22 at 00:17

1 Answers1

0

You could use the bslib package, instead of shinythemes. There's a function called bs_themer() that gives you an extra live UI to edit general aesthetics. It also prints to the console the code that you changed to be put inside the UI.R file

Ryan M
  • 18,333
  • 31
  • 67
  • 74