Home > Mobile >  Shiny remove extra row added by external link in navbar tab panel
Shiny remove extra row added by external link in navbar tab panel

Time:01-17

I'm trying to add an external link to the tab panel title in a shiny navbar. The link itself works fine, but it moves the tab with the link into a separate row.

enter image description here

A work-around is to do something like

  1. Observe when Tab2 is pressed
  2. Navigate to the URL
library(shiny)

ui <- navbarPage(
  title = "", 
  id = "navbar",
  header = "",
  tabsetPanel(
    id = "tabs",
    tabPanel(title = "Tab1"),
    tabPanel(title = "Tab2")
  ) 
)

server <- function(input, output, session) {
  
  observeEvent(input$tabs, {
    print(input$tabs)
    
    if( input$tabs == "Tab2" ) {
      browseURL("https://www.google.com/")
    }
  })
  
}

shinyApp(ui, server)
  • Related