Link to a tab or panel in a brilliant app

How can I remove a link from this shiny part to parts that are located on other tabs / panels?

Update

The solution that I developed below works for the explicit case of binding to tabs / panels (and what I requested).

However, I would be interested to learn about more general ways to connect parts of a brilliant application.

Example

I want to associate panel A with panel B, but I'm not quite sure what I need to specify as an action when I click an action link in panel A.

The value #tab-4527-2 came from studying the HTML ui output, but I just saw that these values ​​change every time I restart the application.

 library(shiny) # UI --------------------------------------------------------------------- ui <- fluidPage( tabsetPanel( tabPanel( "A", p(), actionLink("link_to_tabpanel_b", "Link to panel B") ), tabPanel( "B", h3("Some information"), tags$li("Item 1"), tags$li("Item 2") ) ) ) # Server ------------------------------------------------------------------ server <- function(input, output, session) { observeEvent(input$link_to_tabpanel_b, { tags$a(href = "#tab-4527-2") }) } shinyApp(ui, server) 
+8
html href r shiny hyperlink
source share
4 answers

We just released a routing library that simplifies binding in Shiny. Here's how it looks in a nutshell.

 make_router( route("<your_app_url>/main", main_page_shiny_ui), route("<your_app_url>/other", other_page_shiny_ui) ) 

More information can be found in this blog post .

+3
source share

The following solution is based on inputs derived from comments.

Note that updateTabsetPanel() owned by shiny , and updateTabItems() is a function of the shinydashboard package. They seem to work interchangeably.

 library(shiny) library(shinydashboard) # UI --------------------------------------------------------------------- ui <- fluidPage( tabsetPanel( id = "panels", tabPanel( "A", p(), actionLink("link_to_tabpanel_b", "Link to panel B") ), tabPanel( "B", h3("Some information"), tags$li("Item 1"), tags$li("Item 2"), actionLink("link_to_tabpanel_a", "Link to panel A") ) ) ) # Server ------------------------------------------------------------------ server <- function(input, output, session) { # observeEvent(input$link_to_tabpanel_b, { # tags$a(href = "#tab-4527-2") # }) observeEvent(input$link_to_tabpanel_b, { newvalue <- "B" updateTabItems(session, "panels", newvalue) }) observeEvent(input$link_to_tabpanel_a, { newvalue <- "A" updateTabsetPanel(session, "panels", newvalue) }) } shinyApp(ui, server) 
+6
source share

You can specify your tabsetPanel id and use updateTabsetPanel with observeEvent

 library(shiny) # UI --------------------------------------------------------------------- ui <- fluidPage( tabsetPanel(id = "demo", tabPanel( "A", p(), actionLink("link_to_tabpanel_b", "Link to panel B") ), tabPanel( "B", h3("Some information"), tags$li("Item 1"), tags$li("Item 2") ) ) ) # Server ------------------------------------------------------------------ server <- function(input, output, session) { observeEvent(input$link_to_tabpanel_b, { updateTabsetPanel(session, "demo", "B") }) } shinyApp(ui, server) 
+1
source share

It is really useful and what I want. According to the code and logic from Rappster. You can set any links. TabsetPanel can be used by updataTabsetPanel . Navbar can use updateNavbarPage(session, inputId, selected = NULL) . They can be found on ?updateTabsetPanel as follows.

 updateTabsetPanel(session, inputId, selected = NULL) updateNavbarPage(session, inputId, selected = NULL) updateNavlistPanel(session, inputId, selected = NULL) 

Note that selected is a new identifier that you can define for TabsetPanel , Navbar or NavlistPanel .

0
source share

All Articles