Build a conditionalPanel condition for a glasstabs widget
Source:R/glass_tabs.R
glassTabCondition.RdReturns a JavaScript condition string that evaluates to TRUE when the
specified glasstabs widget has a given active tab. Pass the result directly
to the condition argument of shiny::conditionalPanel().
Arguments
- id
The
idpassed toglassTabsUI(). Inside a Shiny module usens("tabs")here (same id you passed toglassTabsUI()), NOT the bare id you pass toglassTabsServer().- value
The tab value string (the
valueargument of the targetglassTabPanel()) that should trigger the condition.
Value
A single character string for use in shiny::conditionalPanel().
Examples
# Basic usage in a plain Shiny app:
if (interactive()) {
library(shiny)
ui <- fluidPage(
useGlassTabs(),
glassTabsUI(
"main",
glassTabPanel("overview", "Overview", selected = TRUE,
p("Always visible.")),
glassTabPanel("details", "Details",
p("Detail pane."))
),
conditionalPanel(
condition = glassTabCondition("main", "details"),
wellPanel("This panel only shows on the Details tab.")
)
)
server <- function(input, output, session) {}
shinyApp(ui, server)
}
# Inside a module — use ns() for the id:
# UI: glassTabCondition(ns("tabs"), "details")
# This produces: "input['mymod-tabs-active_tab'] === 'details'"