Is there a way to make the title in navbarPage() function becomes a tab?

So the idea is that I want users to click on the title and go to a welcoming tab.

Welcome to RStudio Community!

Yeah, sure thing, that's possible. The title of a navbarPage/etc can be an actionLink that sends the user to a certain tab with updateNavbarPage. Same with a tabsetPanel with updateTabsetPanel.

Here's an example:

library(shiny)

ui <- fluidPage(
  navbarPage(
    id = "my-page",
    title = actionLink("title", "My Application"),
    tabPanel(
      "Home",
      "This is the home page."
    ),
    tabPanel(
      "Help",
      "This is the help page."
    )
  )
)

server <- function(input, output, session) {
  observeEvent(input$title, {
    updateNavbarPage(session, "my-page", "Home")
  })
}

shinyApp(ui, server)

Example taken with minor modifications from this StackOverflow answer.

Thank you! That worked! But I did not want to show the Home tab title in the nav bar so i just used an empty string and set the display to none instead as a solution. Maybe there is a better way to do it. :sweat_smile:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.