bslib icon indicating copy to clipboard operation
bslib copied to clipboard

Add a `nav_get(target)` function to obtain the currenly selected nav_panel of a target nav container

Open ariebh opened this issue 2 years ago • 1 comments

It's currently possible to select, insert, remove, show or hide a nav panel of a parent container, but it isn't possible to query what panel is currently selected.

This feature would be useful for programmatically updating page contents based on the query result.

ariebh avatar Jun 28 '23 08:06 ariebh

It isn't possible to query what panel is currently selected.

Are you aware that by adding an id (to the navset_() container) you can read the selected panel via an input value?

library(shiny)
library(bslib)

ui <- page_fluid(
  navset_card_tab(
    id = "tabs",
    nav_panel("A", "a"),
    nav_panel("B", "b")
  )
)

server <- function(input, output, session) {
  observe(print(input$tabs))
}

shinyApp(ui, server)

cpsievert avatar Jun 28 '23 13:06 cpsievert