【问题标题】:Aligning Multiple Action Buttons in Shiny Dashboard Header在闪亮的仪表板标题中对齐多个操作按钮
【发布时间】:2021-03-21 06:21:51
【问题描述】:

This SO post 描述了如何将actionButton 添加到shinydashboarddashboardHeader 的右上角。我想在dashboardHeader 中添加两个相邻的操作按钮。如何将按钮放置在标题栏中,以免它们重叠?更具体地说,有没有办法将按钮向左移动并在dashboardHeader 中垂直居中?

【问题讨论】:

    标签: r shiny shinydashboard action-button


    【解决方案1】:

    也许你正在寻找这个

    ui <- dashboardPage(
      dashboardHeader(title = div("Testing Work Space", 
                                  img(src = 'YBS.png',
                                      title = "Just a Test Application", height = "30px"),
                                  style = "position: relative; margin:-3px 0px 0px 5px; display:right-align;"
                                 ), 
      titleWidth=350,
      tags$li(div(
                img(src = 'YBS.png',
                    title = "A Test Graphics Application", height = "30px"),
                style = "padding-top:15px; padding-right:100px;"),
              class = "dropdown"),
      tags$li(a(href = 'http://www.cnn.com',
                icon("power-off"),
                title = "CNN Home"),
              class = "dropdown"),
      tags$li(a(href =  'https://en.wikipedia.org/wiki/Mouse', 
                tags$img(src = 'mouse.png', height = "30px"),
                title = "Mouse Home"),
              class = "dropdown")
      ),
      dashboardSidebar(),
      dashboardBody()
    )
    
    server <- function(input, output,session) {}
    
    shinyApp(ui, server)
    

    您可以调整paddingmargin 以满足您的需求。此外,您可以添加多个操作按钮。

    【讨论】:

      【解决方案2】:

      我无法直接回答您的问题,因为我只使用过 Flexdashboard。但是有一个 shinyWidgets 包,其中包含一个 DropDown 小部件,允许您将多个小部件嵌入到 DropDown 中。因此,如果仪表板标题只允许单个小部件,您可以使用下拉小部件间接访问多个小部件请参阅:

      http://shinyapps.dreamrs.fr/shinyWidgets/

      还有下拉菜单和sweetalert 菜单项。那里的示例下拉列表包含指向底层 shinyWidgets 代码的链接。

      【讨论】:

        猜你喜欢
        • 2018-08-02
        • 2015-12-12
        • 2018-02-24
        • 2018-08-05
        • 1970-01-01
        • 2018-05-14
        • 2022-01-04
        • 2021-10-26
        • 2018-02-20
        相关资源
        最近更新 更多