I wanted to combine the multiple questions/answers with my own reproducible example. This combines Marsenau, dracodoc, and Vincent's answer. And responds to Captain Hat's comment.
Dynamic link solution
UI side
uiOutput("ui_open_tab_button")
Server-side (where input$slider is an example of a dynamic element)
output$ui_open_tab_button <- renderUI({
shiny::a(
h4(icon("th"),
paste0("Wiki Link Number: ",input$slider),
class = "btn btn-default action-button",
style = "fontweight:600"),
target = "_blank",
href = paste0("https://en.wikipedia.org/wiki/",input$slider)
)
})
Complete Example
library("shiny")
library("shinydashboard")
ui <- dashboardPage(
dashboardHeader(title = "Basic dashboard"),
dashboardSidebar(
sliderInput("slider", "Wiki Link Control", 1, 10, 1)
),
dashboardBody(
box(title = "UI Only Link", p("From Marsenau... Uses onclick"),
actionButton(
inputId='ab2',
label="Wiki Main Link",
icon = icon("th"),
onclick=paste0("window.open('https://en.wikipedia.org/wiki/','_blank')")
)
),
box(title = "Dynamic link", p("From dracodoc and Vincent... answers Captain Hat's question"),
uiOutput("ui_open_tab_button")
),
fluidRow(
htmlOutput("wiki")
)
)
)
server <- function(input, output) {
output$ui_open_tab_button <- renderUI({
shiny::a(
h4(icon("th"),
paste0("Wiki Link Number: ",input$slider),
class = "btn btn-default action-button",
style = "fontweight:600"),
target = "_blank",
href = paste0("https://en.wikipedia.org/wiki/",input$slider)
)
})
output$wiki <- renderUI({
tags$iframe(src=paste0("https://en.wikipedia.org/wiki/",input$slider), height=1000, width="100%")
})
}
shinyApp(ui, server, options = list(launch.browser=T))