Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert a link into the navbar in shiny

Tags:

r

shiny

I have some trouble with inserting a link into a navbar with navbarPage in shiny. I can put a link but the navbar looks weird. Does anyone know how to fix it ?

To produce an app with a link in the navbar :

library(shiny)
runApp(list(
  ui = navbarPage(
      title="My App",
    tabPanel("tab1"),
    tabPanel("tab2"),
    tabPanel(a(href="http://stackoverflow.com", "stackoverflow"))),
  server = function(input, output) { }
))

With shiny_0.9.1

Thanks !

EDIT : A colleague show me a workaround, it consist of puting the link we want in panel 3 into the headerof panel 2.

An app to demonstrate this and the solution from @ 20050 8519 21102 26896 16937 for the link in the title's app :

runApp(list(
  ui = navbarPage(
    title=HTML("<a href=\"http://stackoverflow.com\">stackoverflow</a>"),
    tabPanel("tab1"),
    tabPanel(HTML("tab2</a></li><li><a href=\"http://stackoverflow.com\">stackoverflow"))
    ),
  server = function(input, output) { }
))
like image 554
Victorp Avatar asked Oct 24 '14 12:10

Victorp


1 Answers

I managed to get it working on a more recent version of Shiny for the left-hand site element of the NavBar, the title, with this:

corner_element = HTML(paste0('<a href=',shQuote(paste0("https://my.page.com/",page_name,"/")), '>', 'Foo', '</a>'))
navbarPage(corner_element, id="page", collapsable=TRUE, inverse=FALSE,
# [...]
)
like image 91
719016 Avatar answered Sep 17 '22 01:09

719016