在闪亮的仪表板中添加动作按钮

时间:2018-02-22 08:50:52

标签: r shiny

以下是我的ui代码

> 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")
>                           
>                   )))
> 
> 

我希望更改密码按钮的格式和样式与帮助相同,但是当我添加actionbutton或actionlink时,无法分别获得相同的格式和对齐。

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

1 个答案:

答案 0 :(得分: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) { }
)