Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201894

How to Switch Between NavBar Tabs with a Button R Shiny

$
0
0

I need the user to click a button and be taken to a different tabPanel of a navbarPage. Here is a simple app where this could be implemented. How can I achieve this?

ui <- shinyUI(
 navbarPage('Test App',
  tabPanel('Page 1',
   p('This is the first tab'), br(),
   actionButton('jumpToP2', 'Jump to Second Tab')
  ),

  tabPanel('Page 2',
   p('This is the second tab'),
   actionButton('jumpToP1', 'Jump to First Tab')
  )
 )
)

server <- shinyServer(function(input, output){
  observeEvent(input$jumpToP2,{
    ## Switch active tab to 'Page 2'
  })

  observeEvent(input$jumpToP1,{
    ## Switch active tab to 'Page 1'
  })
})

shinyApp(ui, server)

Viewing all articles
Browse latest Browse all 201894

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>