-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
showTab.Rd
84 lines (73 loc) · 2.47 KB
/
showTab.Rd
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
% 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, select = FALSE, session = getDefaultReactiveDomain())
hideTab(inputId, target, session = getDefaultReactiveDomain())
}
\arguments{
\item{inputId}{The \code{id} of the \code{tabsetPanel} (or
\code{navlistPanel} or \code{navbarPage}) in which to find
\code{target}.}
\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{select}{Should \code{target} be selected upon being shown?}
\item{session}{The shiny session within which to call this function.}
}
\description{
Dynamically hide or show a \code{\link[=tabPanel]{tabPanel()}} (or a
\code{\link[=navbarMenu]{navbarMenu()}})from an existing \code{\link[=tabsetPanel]{tabsetPanel()}},
\code{\link[=navlistPanel]{navlistPanel()}} or \code{\link[=navbarPage]{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]{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 <- navbarPage("Navbar page", id = "tabs",
tabPanel("Home",
actionButton("hideTab", "Hide 'Foo' tab"),
actionButton("showTab", "Show 'Foo' tab"),
actionButton("hideMenu", "Hide 'More' navbarMenu"),
actionButton("showMenu", "Show 'More' navbarMenu")
),
tabPanel("Foo", "This is the foo tab"),
tabPanel("Bar", "This is the bar tab"),
navbarMenu("More",
tabPanel("Table", "Table page"),
tabPanel("About", "About page"),
"------",
"Even more!",
tabPanel("Email", "Email page")
)
)
server <- function(input, output, session) {
observeEvent(input$hideTab, {
hideTab(inputId = "tabs", target = "Foo")
})
observeEvent(input$showTab, {
showTab(inputId = "tabs", target = "Foo")
})
observeEvent(input$hideMenu, {
hideTab(inputId = "tabs", target = "More")
})
observeEvent(input$showMenu, {
showTab(inputId = "tabs", target = "More")
})
}
shinyApp(ui, server)
}
}
\seealso{
\code{\link[=insertTab]{insertTab()}}
}