【问题标题】:Adding actionbutton in shiny dashboardheader在闪亮的仪表板标题中添加操作按钮
【发布时间】:2018-08-02 01:09:32
【问题描述】:

下面是我的用户界面代码

> dashboardHeader(title = uiOutput("flex_logo"),
>                   tags$li(class = "dropdown",
>                           tags$a("Help",target="_blank",href="Flex-Forecasting_Usage_Guidelines.pdf",
>                            style="font-weight: bold;color:white;")),
>                   tags$li(class = "dropdown",tags$a(href="mailto:flex-forecasting_support@eclerx.com?subject=
> flex-forecasting","Contact us",style="font-weight:
> bold;color:white;")),
>                   tags$li(class = "dropdown",tags$a("Change password",actionLink("ChangePassword","Change
> Password"),style="font-weight: bold;color:white;")),
>                   tags$li(class ="dropdown",dropdownMenu(type = "notifications",
>                           notificationItem(text = "No new notification",status = "success")
>                          # notificationItem(text = "Nnet & Nnetx takes time to converge",status = "success")
>                           
>                   )))
> 
> 

我希望更改密码按钮的格式和样式与帮助和联系我们相同,但是当我添加操作按钮或操作链接时,无法分别获得相同的格式和对齐方式。

或者,如果我添加一个标记名(更改密码它具有相同的格式,但我想进一步将其与观察功能链接

【问题讨论】:

  • 您能否提供一个最小且完全可复制的代码?

标签: r shiny


【解决方案1】:

您将style 参数提供给tag$a,因此您正在对超链接而不是按钮进行样式化。您应该将其用于actionLink,即:actionLink("ChangePassword", "Change Password", style = "font-weight: bold;color:white;")

此外,您不必将 actionButton 包装在 tag$a 中,并且由于您对多个项目使用相同的 style,因此您可以创建具有所需样式的自定义 css 类,它将适用于每个标签同班

shinyApp(
  ui = dashboardPage(
    dashboardHeader(
      tags$li(class = "dropdown", tags$a(href = "", class = "my_class", "Help", target="_blank")), 
      tags$li(class = "dropdown", tags$a(href = "", class = "my_class", "Contact us")),
      tags$li(class = "dropdown", actionLink("ChangePassword", "Change Password", class = "my_class"))),
    dashboardSidebar(),
    dashboardBody(tags$head(
      tags$style(HTML("
                      .my_class {
                      font-weight: bold;
                      color:white;
                      }"))
    )),
    title = "Dashboard example"
  ),
  server = function(input, output) { }
)

【讨论】:

    猜你喜欢
    • 2015-12-12
    • 2021-03-21
    • 2022-01-04
    • 2018-02-24
    • 2020-01-22
    • 2018-05-14
    • 2018-08-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多