Skip to contents

Render a collection of nav() items into a container.

Usage

navs_tab(..., id = NULL, selected = NULL, header = NULL, footer = NULL)

navs_pill(..., id = NULL, selected = NULL, header = NULL, footer = NULL)

navs_pill_list(
  ...,
  id = NULL,
  selected = NULL,
  header = NULL,
  footer = NULL,
  well = TRUE,
  fluid = TRUE,
  widths = c(4, 8)
)

navs_hidden(..., id = NULL, selected = NULL, header = NULL, footer = NULL)

navs_bar(
  ...,
  title = NULL,
  id = NULL,
  selected = NULL,
  sidebar = NULL,
  fillable = FALSE,
  position = c("static-top", "fixed-top", "fixed-bottom"),
  header = NULL,
  footer = NULL,
  bg = NULL,
  inverse = "auto",
  collapsible = TRUE,
  fluid = TRUE
)

navs_tab_card(
  ...,
  id = NULL,
  selected = NULL,
  title = NULL,
  sidebar = NULL,
  header = NULL,
  footer = NULL,
  height = NULL,
  full_screen = FALSE,
  wrapper = card_body
)

navs_pill_card(
  ...,
  id = NULL,
  selected = NULL,
  title = NULL,
  sidebar = NULL,
  header = NULL,
  footer = NULL,
  height = NULL,
  placement = c("above", "below"),
  full_screen = FALSE,
  wrapper = card_body
)

Arguments

...

a collection of nav() items.

id

a character string used for dynamically updating the container (see nav_select()).

selected

a character string matching the value of a particular nav() item to selected by default.

header

UI element(s) (tags) to display above the nav content.

footer

UI element(s) (tags) to display below the nav content.

well

TRUE to place a well (gray rounded rectangle) around the navigation list.

fluid

TRUE to use fluid layout; FALSE to use fixed layout.

widths

Column widths of the navigation list and tabset content areas respectively.

title

A (left-aligned) title to place in the card header/footer. If provided, other nav items are automatically right aligned.

sidebar

A sidebar() component to display on every nav() page.

fillable

Whether or not to allow fill items to grow/shrink to fit the browser window. If TRUE, all nav() pages are fillable. A character vector, matching the value of nav()s to be filled, may also be provided. Note that, if a sidebar is provided, fillable makes the main content portion fillable.

position

Determines whether the navbar should be displayed at the top of the page with normal scrolling behavior ("static-top"), pinned at the top ("fixed-top"), or pinned at the bottom ("fixed-bottom"). Note that using "fixed-top" or "fixed-bottom" will cause the navbar to overlay your body content, unless you add padding, e.g.: tags$style(type="text/css", "body {padding-top: 70px;}")

bg

a CSS color to use for the navbar's background color.

inverse

Either TRUE for a light text color or FALSE for a dark text color. If "auto" (the default), the best contrast to bg is chosen.

collapsible

TRUE to automatically collapse the navigation elements into a menu when the width of the browser is less than 940 pixels (useful for viewing on smaller touchscreen device)

height

Any valid CSS unit (e.g., height="200px").

full_screen

If TRUE, an icon will appear when hovering over the card body. Clicking the icon expands the card to fit viewport size. Consider pairing this feature with card_body_fill() to get output that responds to changes in the size of the card.

wrapper

A function (which returns a UI element) to call on unnamed arguments in ... which are not already card item(s) (like card_header(), card_body(), etc.). Note that non-card items are grouped together into one wrapper call (e.g. given card("a", "b", card_body("c"), "d"), wrapper would be called twice, once with "a" and "b" and once with "d"). Consider setting wrapper to card_body_fill if the entire card wants responsive sizing or NULL to avoid wrapping altogether

placement

placement of the nav items relative to the content.

See also

Examples


library(shiny)

nav_items <- function(prefix) {
  list(
    nav("a", paste(prefix, ": tab a content")),
    nav("b", paste(prefix, ": tab b content")),
    nav_item(
      tags$a(icon("github"), "Shiny", href = "https://github.com/rstudio/shiny", target = "_blank")
    ),
    nav_spacer(),
    nav_menu(
      "Other links", align = "right",
      nav("c", paste(prefix, ": tab c content")),
      nav_item(
        tags$a(icon("r-project"), "RStudio", href = "https://rstudio.com", target = "_blank")
      )
    )
  )
}

if (interactive()) {
  shinyApp(
    page_navbar(
      title = "page_navbar()",
      bg = "#0062cc",
      !!!nav_items("page_navbar()"),
      footer = div(
        style = "width:80%; margin: 0 auto",
        h4("navs_tab()"),
        navs_tab(!!!nav_items("navs_tab()")),
        h4("navs_pill()"),
        navs_pill(!!!nav_items("navs_pill()")),
        h4("navs_tab_card()"),
        navs_tab_card(!!!nav_items("navs_tab_card()")),
        h4("navs_pill_card()"),
        navs_pill_card(!!!nav_items("navs_pill_card()")),
        h4("navs_pill_list()"),
        navs_pill_list(!!!nav_items("navs_pill_list()"))
      )
    ),
    function(...) { }
  )
}