Skip to contents

Update a stepper from the server

Usage

update_shad_stepper(
  id,
  active = NULL,
  error = NULL,
  session = shiny::getDefaultReactiveDomain()
)

Arguments

id

Input id (namespaced automatically).

active

Optional new active step (1-based).

error

Optional named list mapping step index (1-based) to a logical: TRUE marks that step as an error, FALSE clears it.

session

The Shiny session.

Value

Invisibly NULL.

Examples

if (interactive()) {
  ui <- page_shad(
    shad_stepper("wizard", shad_step("Account"), shad_step("Profile"),
                 shad_step("Review")),
    shad_button("Continue", inputId = "forward")
  )
  server <- function(input, output, session) {
    step <- shiny::reactiveVal(1)
    shiny::observeEvent(input$forward, {
      step(min(step() + 1, 3))
      update_shad_stepper("wizard", active = step())
    })
  }
  shiny::shinyApp(ui, server)
}