Home > Blockchain >  R Shiny hyperlink with custom font size, color, and open link in new browser tab
R Shiny hyperlink with custom font size, color, and open link in new browser tab

Time:12-13

this question is a follow-up of previous post Create URL hyperlink in R Shiny? .

I'm using the solution shared there, namely:

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)
    })
  })
)

The solution above works fine. However, I would need to:

  • customize the font size and color
  • make sure the link opens up a new page in a new browser tab. I can't find a way to achieve these two goals and I'm not familiar with HTML. Any help would be much appreciated. Thanks

CodePudding user response:

Use style to change font size and color and target="_blank" to open the link in new tab.

library(shiny)

runApp(
  list(ui = fluidPage(
    uiOutput("tab")
  ),
  server = function(input, output, session){
    url <- a("Google Homepage", href="https://www.google.com/", 
             style = "color:orange;font-size:18px", target="_blank")
    output$tab <- renderUI({
      tagList("URL link:", url)
    })
  })
)
  • Related