问题
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