How to include an action link into a button's label?

不羁的心 提交于 2020-03-20 10:39:03

问题


My goal is to include an action link (that displays a help text) into the label of a selectInput button.

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)

I guess the solution is to use label = HTML(...), but I do not know how to rewrite the action link in plain html.


回答1:


  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
  )



回答2:


You can also use tags such as a and p

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)



来源:https://stackoverflow.com/questions/54443020/how-to-include-an-action-link-into-a-buttons-label

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!