代码之家  ›  专栏  ›  技术社区  ›  thothal

shinydashboard::box标题中的样式shinyWidget::dropdownButton

  •  1
  • thothal  · 技术社区  · 6 年前

    背景

    shinyWidget::dropdownButton 在一个 shinydashboard::box box(..., collapsible = TRUE) .

    HTML 我自己。

    css ,因为下拉列表中的元素部分是白底白字(我想这是有道理的,因为他们是班级的(大)孩子) .box-tools )

    我想要什么

    Dropdown in the Body

    目标:

    Dropdown in the Header

    现状: 标题中的下拉列表

    我怎样才能做到这一点?哪个 css格式 css格式


    代码

    library(shiny)
    library(shinydashboard)
    library(shinyWidgets)
    library(shinyjs)
    
    makeDropDown <- function(i) {
      dropdownButton(
        h3("Heading"),
        selectInput(paste0("sel", i), "Select:", LETTERS),
        downloadButton(paste0("down", i), "Load"),
        circle = FALSE,
        icon = icon("cog")
      )
    }
    
    ui <- dashboardPage(
      dashboardHeader(),
      dashboardSidebar(),
      dashboardBody(
        useShinyjs(),
        box(solidHeader = TRUE,
            status = "info",
            title = "Box",
            div(
              makeDropDown(1),
              class = "box-tools pull-right",
              id = "moveme"
            ),
            makeDropDown(2)
        )
      )
    )
    
    server <- function(input, output, session) {
      runjs("$('.box-header').append($('#moveme').detach())")
    }
    
    shinyApp(ui, server)
    
    1 回复  |  直到 6 年前
        1
  •  1
  •   Victorp    6 年前

    !important 要控制外观:

    makeDropDown <- function(i) {
      dropdownButton(
        tags$div(
          style = "color: black !important;", # for text
          h3("Heading"),
          selectInput(paste0("sel", i), "Select:", LETTERS),
          downloadButton(
            outputId = paste0("down", i), label = "Load", 
            style = "background-color: #f4f4f4 !important; color: #444 !important; border: 1px solid #ddd !important;" # for button
          )
        ),
        circle = FALSE,
        icon = icon("cog")
      )
    }
    

    否则,也许@DivadNojnarg在 shinydashboardPlus