diff --git a/R/sysdata.rda b/R/sysdata.rda index 679e5ba3c..027f090f6 100644 Binary files a/R/sysdata.rda and b/R/sysdata.rda differ diff --git a/R/utils-deps.R b/R/utils-deps.R index 5d0ce5629..cbf4b161e 100644 --- a/R/utils-deps.R +++ b/R/utils-deps.R @@ -24,7 +24,9 @@ component_dependency_css <- function(name) { # Run-time (Sass) component styles component_dependency_sass <- function(theme, name) { - if (!is_bs_theme(theme) || identical(theme, bs_theme())) { + precompiled <- isTRUE(get_precompiled_option()) + default_theme <- !is_bs_theme(theme) || identical(theme, bs_theme()) + if (precompiled && default_theme) { component_dependency_css(name) } else { component_dependency_sass_(theme, name) diff --git a/man/navset.Rd b/man/navset.Rd index cf8e1c2e4..8b33e101b 100644 --- a/man/navset.Rd +++ b/man/navset.Rd @@ -154,6 +154,179 @@ together into one \code{wrapper} call (e.g. given \code{card("a", "b", card_body \description{ Render a collection of \code{\link[=nav_panel]{nav_panel()}} items into a container. } +\details{ +\subsection{A basic example}{ + +This first example creates a simple tabbed navigation container with two +tabs. The tab name and the content of each tab are specified in the +\code{nav_panel()} calls and \code{navset_tab()} creates the tabbed navigation +around these two tabs. + +\if{html}{\out{
}}\preformatted{library(htmltools) + +navset_tab( + nav_panel(title = "One", p("First tab content.")), + nav_panel(title = "Two", p("Second tab content.")) +) +}\if{html}{\out{
}} + +\figure{navset-tab-basic.png}{Screenshot of a basic navset_tab() example.} + +In the rest of the examples, we’ll include links among the tabs (or +pills) in the navigation controls. + +\if{html}{\out{
}}\preformatted{link_shiny <- tags$a(shiny::icon("github"), "Shiny", href = "https://github.com/rstudio/shiny", target = "_blank") +link_posit <- tags$a(shiny::icon("r-project"), "Posit", href = "https://posit.co", target = "_blank") +}\if{html}{\out{
}} +} + +\subsection{\code{navset_tab()}}{ + +You can fully customize the controls in the navigation component. In +this example, we’ve added a direct link to the Shiny repository using +\code{nav_item()}. We’ve also included a dropdown menu using \code{nav_menu()} +containing an option to select a third tab panel and another direct link +to Posit’s website. Finally, we’ve separated the primary tabs on the +left from the direct link and dropdown menu on the right using +\code{nav_spacer()}. + +\if{html}{\out{
}}\preformatted{navset_tab( + nav_panel(title = "One", p("First tab content.")), + nav_panel(title = "Two", p("Second tab content.")), + nav_spacer(), + nav_item(link_shiny), + nav_menu( + title = "Other links", + align = "right", + nav_panel("Three", p("Third tab content")), + nav_item(link_posit) + ) +) +}\if{html}{\out{
}} + +\figure{navset-tab.png}{Screenshot of a navset_tab() example.} +} + +\subsection{\code{navset_pill()}}{ + +\code{navset_pill()} creates a navigation container that behaves exactly like +\code{navset_tab()}, but the tab toggles are \emph{pills} or button-shaped. + +\if{html}{\out{
}}\preformatted{navset_pill( + nav_panel(title = "One", p("First tab content.")), + nav_panel(title = "Two", p("Second tab content.")), + nav_spacer(), + nav_item(link_shiny), + nav_menu( + title = "Other links", + align = "right", + nav_panel("Three", p("Third tab content")), + nav_item(link_posit) + ) +) +}\if{html}{\out{
}} + +\figure{navset-pill.png}{Screenshot of a navset_pill() example.} +} + +\subsection{\code{navset_card_tab()}}{ + +The tabbed navigation container can also be used in a \code{card()} component +thanks to \code{navset_card_tab()}. Learn more about this approach in the +\href{https://pkgs.rstudio.com/bslib/articles/cards.html}{article about Cards}, including +how to add \href{https://pkgs.rstudio.com/bslib/articles/sidebars.html#multi-page-layout}{a shared sidebar} +to all tabs in the card using the \code{sidebar} argument of +\code{navset_card_tab()}. + +\if{html}{\out{
}}\preformatted{navset_card_tab( + nav_panel(title = "One", p("First tab content.")), + nav_panel(title = "Two", p("Second tab content.")), + nav_spacer(), + nav_item(link_shiny), + nav_menu( + title = "Other links", + align = "right", + nav_panel("Three", p("Third tab content")), + nav_item(link_posit) + ) +) +}\if{html}{\out{
}} + +\figure{navset-tab-card.png}{Screenshot of a navset_tab_card() example.} +} + +\subsection{\code{navset_card_pill()}}{ + +Similar to \code{navset_pill()}, \code{navset_card_pill()} provides a pill-shaped +variant to \code{navset_card_tab()}. You can use the \code{placement} argument to +position the navbar \code{"above"} or \code{"below"} the card body. + +\if{html}{\out{
}}\preformatted{navset_card_pill( + placement = "above", + nav_panel(title = "One", p("First tab content.")), + nav_panel(title = "Two", p("Second tab content.")), + nav_spacer(), + nav_item(link_shiny), + nav_menu( + title = "Other links", + align = "right", + nav_panel("Three", p("Third tab content")), + nav_item(link_posit) + ) +) +}\if{html}{\out{
}} + +\figure{navset-card-pill.png}{Screenshot of a navset_card_pill() example.} +} + +\subsection{\code{navset_pill_list()}}{ + +Furthermore, \code{navset_pill_list()} creates a vertical list of navigation +controls adjacent to, rather than on top of, the tab content panels. + +\if{html}{\out{
}}\preformatted{navset_pill_list( + nav_panel(title = "One", p("First tab content.")), + nav_panel(title = "Two", p("Second tab content.")), + nav_spacer(), + nav_item(link_shiny), + nav_menu( + title = "Other links", + align = "right", + nav_panel("Three", p("Third tab content")), + nav_item(link_posit) + ) +) +}\if{html}{\out{
}} + +\figure{navset-pill-list.png}{Screenshot of a navset_pill_list() example.} +} + +\subsection{\code{page_navbar()}}{ + +Finally, \code{page_navbar()} provides full-page navigation container similar +to \code{navset_tab()} but where each \code{nav_panel()} is treated as a full page +of content and the navigation controls appear in a top-level navigation +bar. + +\if{html}{\out{
}}\preformatted{page_navbar( + title = "My App", + bg = "#0062cc", + nav_panel(title = "One", p("First page content.")), + nav_panel(title = "Two", p("Second page content.")), + nav_spacer(), + nav_item(link_shiny), + nav_menu( + title = "Other links", + align = "right", + nav_panel("Three", p("Third page content.")), + nav_item(link_posit) + ) +) +}\if{html}{\out{
}} + +\figure{page-navbar.png}{Screenshot of a page_navbar() example.} +} +} \seealso{ \code{\link[=nav_panel]{nav_panel()}}, \code{\link[=nav_select]{nav_select()}}. }