Skip to content

Suggestion: make {reactable} interact correctly with {bs4Dash}'s dark-mode #290

Open
@eastclintw00d

Description

@eastclintw00d

Please have a look at the following examples:

Example 1: In dark-mode font color changes to white and becomes unreadable because of the white background.

library(shiny)
library(bs4Dash)
library(reactable)

shinyApp(
  ui = dashboardPage(
    header = dashboardHeader(),
    sidebar = dashboardSidebar(),
    body = dashboardBody(
      box(width = 4, reactableOutput("table"))
    ),
    title = "DashboardPage"
  ),
  server = function(input, output) { 
    output$table <- renderReactable({
      data.frame(
        col1 = paste0("col1_", 1:10),
        col2 = paste0("col2_", 1:10),
        col3 = paste0("col3_", 1:10),
        col4 = paste0("col4_", 1:10),
        col5 = paste0("col5_", 1:10),
        col6 = paste0("col6_", 1:10),
        col7 = paste0("col7_", 1:10),
        col8 = paste0("col8_", 1:10),
        col9 = paste0("col9_", 1:10)
      ) |> 
        reactable(
          columns = list(
            col1 = colDef(sticky = "left"),
            col9 = colDef(sticky = "right")
          )
        )
    })
  }
)

Example 2: Setting background to "transparent" solves the dark-mode readability issue but create issues with sticky columns.

library(shiny)
library(bs4Dash)
library(reactable)

shinyApp(
  ui = dashboardPage(
    header = dashboardHeader(),
    sidebar = dashboardSidebar(),
    body = dashboardBody(
      box(width = 4, reactableOutput("table"))
    ),
    title = "DashboardPage"
  ),
  server = function(input, output) { 
    output$table <- renderReactable({
      data.frame(
        col1 = paste0("col1_", 1:10),
        col2 = paste0("col2_", 1:10),
        col3 = paste0("col3_", 1:10),
        col4 = paste0("col4_", 1:10),
        col5 = paste0("col5_", 1:10),
        col6 = paste0("col6_", 1:10),
        col7 = paste0("col7_", 1:10),
        col8 = paste0("col8_", 1:10),
        col9 = paste0("col9_", 1:10)
      ) |> 
        reactable(
          theme = reactableTheme(backgroundColor = "transparent"),
          columns = list(
            col1 = colDef(sticky = "left"),
            col9 = colDef(sticky = "right")
          )
        )
    })
  }
)

As imho the package bs4Dash is becoming popular it would be a nice feature to have a built-in dark-mode functionality.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions