40

My code:

library(shiny)
runApp(
  list(ui = fluidPage(
     uiOutput("tab")
    ),
  server = function(input, output, session){
    url <- a("Google Homepage", href="https://www.google.com/")
    output$tab <- renderUI({
      paste("URL link:", url)
    })
  })
)

Current output:

URL link: <a href="https://www.google.com/">Google Homepage</a>

Desired output:

URL link: Google Homepage

where Google Homepage is a clickable hyperlink.

I'm currently using the renderUI/uiOutput duo as instructed here: how to create a hyperlink interactively in shiny app?

Community
  • 1
  • 1
warship
  • 2,924
  • 6
  • 39
  • 65

2 Answers2

55

By using paste, you're treating the url as a string. The function you want to use here is tagList:

runApp(
  list(ui = fluidPage(
     uiOutput("tab")
    ),
  server = function(input, output, session){
    url <- a("Google Homepage", href="https://www.google.com/")
    output$tab <- renderUI({
      tagList("URL link:", url)
    })
  })
)
DeanAttali
  • 25,268
  • 10
  • 92
  • 118
27

You can use html tags whatever you want to tag

    tags$a(href="www.rstudio.com", "Click here!")
## <a href="www.rstudio.com">Click here!</a>
Seyma Kalay
  • 2,037
  • 10
  • 22