update_tabler_tab_item: Update the currently selected tabler_navbar_menu_item on the...

Description Usage Arguments Examples

View source: R/tabler.R

Description

Update the currently selected tabler_navbar_menu_item on the client

Usage

1
update_tabler_tab_item(inputId, value, session = getDefaultReactiveDomain())

Arguments

inputId

tabler_navbar_menu id.

value

New target.

session

Shiny session.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
if (interactive()) {
 library(shiny)
 # example with input binding: inputId is required for tabler_navbar_menu!!!
 ui <- tabler_page(
  tabler_navbar(
    brand_url = "https://preview-dev.tabler.io",
    brand_image = "https://preview-dev.tabler.io/static/logo.svg",
    nav_menu = tabler_navbar_menu(
      id = "current_tab",
      tabler_navbar_menu_item(
        text = "Tab 1",
        icon = NULL,
        tabName = "tab1",
        selected = TRUE
      ),
      tabler_navbar_menu_item(
        text = "Tab 2",
        icon = NULL,
        tabName = "tab2"
      )
    ),
    tabler_button("update", "Change tab", icon = icon("exchange-alt"))
  ),
  tabler_body(
    tabler_tab_items(
      tabler_tab_item(
        tabName = "tab1",
        sliderInput(
          "obs",
          "Number of observations:",
          min = 0,
          max = 1000,
          value = 500
        ),
        plotOutput("distPlot")
      ),
      tabler_tab_item(
        tabName = "tab2",
        p("Second Tab")
      )
    ),
    footer = tabler_footer(
      left = "Rstats, 2020",
      right = a(href = "https://www.google.com")
    )
  )
 )
 server <- function(input, output, session) {
   output$distPlot <- renderPlot({
     hist(rnorm(input$obs))
   })

   observeEvent(input$current_tab, {
     showNotification(
       paste("Hello", input$current_tab),
       type = "message",
       duration = 1
     )
   })

   observeEvent(input$update, {
     newTab <- if (input$current_tab == "tab1") "tab2" else "tab1"
     update_tabler_tab_item("current_tab", newTab)
   })
 }
 shinyApp(ui, server)
}

DivadNojnarg/outstanding-shiny-ui-code documentation built on Nov. 2, 2021, 12:03 p.m.