updateTabsetPanel_dsfr

updateTabsetPanel_dsfr(
  inputId,
  selected = NULL,
  session = shiny::getDefaultReactiveDomain()
)

Arguments

inputId

inputId du tabsetPanel_dsfr

selected

titre du tab à afficher (paramètre title utilisé dans tabPanel_dsfr())

session

session shiny

Valeur de retour

html

Examples

if (interactive()){
  library(shiny)
  library(shinygouv)
  shinyApp(
    ui = fluidPage_dsfr(
    fluidRow_dsfr(
      column_dsfr(
        12,
        h3("Demo tabsetPanel_dsfr() et tabPanel_dsfr()"),
        # Adding space to the column
        # https://www.systeme-de-design.gouv.fr/elements-d-interface/fondamentaux-techniques/espacement
        extra_class = "fr-my-6w"
      ),
      column_dsfr(
        12,
        tabsetPanel_dsfr(
          "testtabpanel",
          tabPanel_dsfr(
            id = "tab1",
            title = "Une prems tab",
            content = tagList(
              h3("Coucou le tab 1")
            )
          ),
          tabPanel_dsfr(
            id = "tab2",
            title = "Une deuxieme tab",
            content = tagList(
              h3("Salut le tab 2")
            )
          )
        )
      )
    ),
    fluidRow_dsfr(
      column_dsfr(
        12,
        actionButton_dsfr(inputId = "showfirsttab",
                     "Afficher le premier onglet"
        ),
        actionButton_dsfr(inputId = "showsecondtab",
                     "Afficher le deuxi\u00e8me onglet"
        )
      )
    )
    ),
    server = function(input, output, session) {
          observeEvent(input$showfirsttab, {
      updateTabsetPanel_dsfr(
        inputId = "testtabpanel",
        selected = "Une prems tab",
        session = session
      )
    })

    observeEvent(input$showsecondtab, {
      updateTabsetPanel_dsfr(
        inputId = "testtabpanel",
        selected = "Une deuxieme tab",
        session = session
      )
    })
    }
  )
}