Files
shiny/man/showTab.Rd
2017-08-04 15:10:08 +01:00

70 lines
1.9 KiB
R

% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/insert-tab.R
\name{showTab}
\alias{showTab}
\alias{hideTab}
\title{Dynamically hide/show a tabPanel}
\usage{
showTab(inputId, target, session = getDefaultReactiveDomain())
hideTab(inputId, target, session = getDefaultReactiveDomain())
}
\arguments{
\item{inputId}{The \code{id} of the \code{tabsetPanel} (or
\code{navlistPanel} or \code{navbarPage})into which \code{tab} will
be inserted/removed.}
\item{target}{The \code{value} of the \code{tabPanel} to be
hidden/shown. See Details if you want to hide/show an entire
\code{navbarMenu} instead.}
\item{session}{The shiny session within which to call this
function.}
}
\description{
Dynamically hide or show a \code{\link{tabPanel}} from an existing
\code{\link{tabsetPanel}}, \code{\link{navlistPanel}} or
\code{\link{navbarPage}}.
}
\details{
For \code{navbarPage}, you can hide/show conventional
\code{tabPanel}s (whether at the top level or nested inside a
\code{navbarMenu}), as well as an entire \code{\link{navbarMenu}}.
For the latter case, \code{target} should be the \code{menuName} that
you gave your \code{navbarMenu} when you first created it (by default,
this is equal to the value of the \code{title} argument).
}
\examples{
## Only run this example in interactive R sessions
if (interactive()) {
ui <- fluidPage(
sidebarLayout(
sidebarPanel(actionButton("show", "Show tab")),
mainPanel(
tabsetPanel(id = "tabs",
tabPanel("Hello", "This is the hello tab"),
tabPanel("Foo", "This is the foo tab"),
tabPanel("Bar", "This is the bar tab")
)
)
)
)
server <- function(input, output, session) {
# Hide tab as soon as app starts up
hideTab(inputId = "tabs", target = "Foo")
observeEvent(input$show, {
showTab(inputId = "tabs", target = "Foo")
})
}
shinyApp(ui, server)
}
# TODO: add example usage for `navbarMenu`
}
\seealso{
\code{\link{insertTab}}
}