
Last chance! 50% off unlimited learning
Sale ends in
A reactive input styled as a navigation control. The navigation input can be
styled as links, tabs, or pills. A nav input is paired with navContent()
and showNavPane()
to create tabbed user interfaces. Observers and reactives
are triggered when a nav choice or menu item is clicked. The reactive value
of a nav input is NULL
or a singleton character string. The value of any
menus in the nav input must be retrieved with its own reactive id.
navInput(id, choices = NULL, values = choices,
selected = values[[1]], ..., appearance = "links", fill = FALSE)updateNavInput(id, choices = NULL, values = choices, selected = NULL,
enable = NULL, disable = NULL,
session = getDefaultReactiveDomain())
A character string specifying the id of the reactive input.
A character vector or list of tag elements specifying the navigation items of the input.
A character vector specifying the values of the input's
chocies, defaults to choices
.
One of values
specifying which choice is selected by
default, defaults to values[[1]]
.
Additional named arguments passed as HTML attributes to the parent element or tag elements passed as child elements to the parent element.
One of "links"
, "pills"
, or "tabs"
specifying the
appearance of the nav input, defaults to "links"
.
One of TRUE
or FALSE
specifying if the nav input fills the
width of its parent element. If TRUE
, the space is divided evenly among
the nav items.
One of values
specifying particular choices to enable or
TRUE
specifying the entire input is enabled, defaults to NULL
.
One of values
specifying particular choices to disable or
TRUE
specifying the entire input is disabled, defaults to NULL
.
A reactive context, defaults to getDefaultReactiveDomain()
.
Use the reactive id of any nav menus to know when a menu item is clicked.
ui <- navInput( id = "navigation", choices = list( "Item 1", "Item 2", menuInput( id = "navMenu", # <- label = "Item 3", choices = c("Choice 1", "Choice 2") ) ), values = c("item1", "item2", "item3") )server <- function(input, output) { observeEvent(input$navMenu, { cat(paste("Click menu item:", input$navMenu, "\n")) }) }
shinyApp(ui, server)
Other inputs: buttonGroupInput
,
buttonInput
, checkbarInput
,
checkboxInput
, chipInput
,
fileInput
, formInput
,
listGroupInput
, menuInput
,
radioInput
, radiobarInput
,
rangeInput
, selectInput
,
textInput
# NOT RUN {
### Nav styled as tabs
navInput(
id = "tabs1",
choices = c(
"Tab 1",
"Tab 2",
"Tab 3"
),
selected = "Tab 1",
appearance = "tabs"
)
### Nav styled as pills
navInput(
id = "tabs2",
choices = paste("Tab", 1:3),
selected = "Tab 1",
appearance = "pills"
)
### Nav with dropdown
navInput(
id = "tabs3",
choices = list(
"Tab 1",
menuInput(
id = "menu1",
label = "Tab 2",
choices = c(
"Action",
"Another action"
)
),
"Tab 2"
),
values = c("tab1", "tab2", "tab3")
)
### Full width nav input
navInput(
id = "tabs4",
choices = paste("Tab", 1:5),
values = paste0("tab", 1:5),
appearance = "pills",
fill = TRUE
)
### Centering a nav input
navInput(
id = "tabs5",
choices = paste("Tab", 1:3)
) %>%
flex(justify = "center")
# }
Run the code above in your browser using DataLab