Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility of WinBox with Dark Theme in bs4Dash #698

Closed
noamanemobidata opened this issue Jun 16, 2024 · 1 comment
Closed

Compatibility of WinBox with Dark Theme in bs4Dash #698

noamanemobidata opened this issue Jun 16, 2024 · 1 comment

Comments

@noamanemobidata
Copy link

Hi!

I'm using bs4Dash with the dark theme. Is there any way to make WinBox reactive to the theme?

Thanks!

@pvictor
Copy link
Member

pvictor commented Jun 17, 2024

Hello,
To achieve this you'll have to add some CSS to your application :

.wb-body { background: #f4f6f9; }
.dark-mode .wb-body { background: #454d55; }

Here's a full example:

library(shiny)
library(shinyWidgets)
library(bs4Dash)

ui <- dashboardPage(
  dashboardHeader(title = "Basic dashboard"),
  dashboardSidebar(),
  dashboardBody(
    
    ##### Winbox part ##### 
    html_dependency_winbox(),
    tags$style(
      ".wb-body { background: #f4f6f9; }",
      ".dark-mode .wb-body { background: #454d55; }"
    ),
    actionButton(inputId = "show", label = "Show WinBox"),
    ##### ##### ##### ##### 
    
    # Boxes need to be put in a row (or column)
    fluidRow(
      box(plotOutput("plot1", height = 250)),
      
      box(
        title = "Controls",
        sliderInput("slider", "Number of observations:", 1, 100, 50)
      )
    )
  )
)

server <- function(input, output) {
  set.seed(122)
  histdata <- rnorm(500)
  
  output$plot1 <- renderPlot({
    data <- histdata[seq_len(input$slider)]
    hist(data)
  })
  
  ##### Winbox part ##### 
  observeEvent(input$show, {
    WinBox(
      title = "WinBox window",
      ui = tagList(
        tags$h2("Hello from WinBox!"),
        "Text content of winbox.",
        selectInput("month", "Select a month:", month.name)
      )
    )
  })
  ##### ##### ##### ##### 
}

shinyApp(ui, server)

Victor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants