如何在按钮的标签中包含动作链接?

时间:2019-01-30 14:36:37

标签: r shiny

我的目标是在selectInput按钮的标签中包含一个操作链接(显示帮助文本)。

library(shiny)

ui <- fluidPage(
  br(),
  selectInput(
    inputId = "some_id", 
    label = "Please choose A or B (get help)",
    choices = c("choice A", "choice B"),
    selected = "choice A",
    selectize = F
  ),
  actionLink(inputId = "action_link", label = "get help")
) # fluidPage

server <- function(input, output) {}

shinyApp(ui, server)

enter image description here

我猜解决方案是使用label = HTML(...),但我不知道如何用纯HTML重写操作链接。

2 个答案:

答案 0 :(得分:2)

  selectInput(
    inputId = "some_id", 
    label = HTML("Please choose A or B", 
                 as.character(actionLink(inputId = 'action_link', label = 'get help'))),
    choices = c("choice A", "choice B"),
    selected = "choice A",
    selectize = F
  )

答案 1 :(得分:2)

您还可以使用tags,例如ap

library(shiny)

ui <- fluidPage(
  br(),
  selectInput(
    inputId = "some_id", 
    label = p("Please choose A or B ",a("get help", href = "https://www.google.com/", target = "_blank")),
    choices = c("choice A", "choice B"),
    selected = "choice A",
    selectize = F
  )
) # fluidPage

server <- function(input, output) {}

shinyApp(ui, server)

enter image description here

相关问题