A collapsible application sidebar with a main content area.
input$<inputId> is a list list(collapsed=, mobileOpen=, active=). Toggle
with the Cmd+B / Ctrl+B shortcut, a shad_sidebar_trigger(), or
shad_sidebar_toggle().
Usage
shad_sidebar_layout(inputId, sidebar, main, class = NULL)
shad_sidebar(..., header = NULL, footer = NULL, collapsed = FALSE)
shad_sidebar_group(label = NULL, ...)
shad_sidebar_item(
value,
label,
icon = NULL,
badge = NULL,
href = NULL,
active = FALSE
)
shad_sidebar_trigger(class = NULL)Arguments
- inputId
Input id.
A
shad_sidebar().- main
The main content.
- class
Extra CSS classes.
- ...
Sidebar body content (typically
shad_sidebar_group()s).Optional header/footer content.
- collapsed
If
TRUE, start collapsed.- label
Optional group label.
- value
Item value (reported as
activewhen clicked).- icon
Optional leading icon.
- badge
Optional trailing badge content.
- href
Optional link; renders an
<a>instead of a<button>.- active
If
TRUE, marks the item active.
See also
shad_sidebar_toggle(), update_shad_sidebar()
Other shadshiny tier-3 components:
shad_accordion(),
shad_alert_dialog(),
shad_carousel(),
shad_collapsible(),
shad_command(),
shad_command_palette(),
shad_context_menu(),
shad_dialog(),
shad_drawer(),
shad_dropdown_menu(),
shad_hover_card(),
shad_menu_parts,
shad_menubar(),
shad_message_scroller(),
shad_navigation_menu(),
shad_pagination(),
shad_popover(),
shad_resizable(),
shad_scroll_area(),
shad_sheet(),
shad_tabs(),
shad_tooltip()
Examples
shad_sidebar_layout("sb",
sidebar = shad_sidebar(
shad_sidebar_group("Platform",
shad_sidebar_item("home", "Home", active = TRUE))),
main = htmltools::div(shad_sidebar_trigger(), "Dashboard"))
#> <div class="shad-sidebar-layout" data-shad="sidebar" id="sb">
#> <div class="shad-sidebar__overlay" hidden></div>
#> <aside class="shad-sidebar" aria-label="Sidebar">
#> <div class="shad-sidebar__content">
#> <div class="shad-sidebar__group">
#> <div class="shad-sidebar__group-label">Platform</div>
#> <ul class="shad-sidebar__menu">
#> <li>
#> <button type="button" class="shad-sidebar__item" data-value="home" data-state="active">
#> <span class="shad-sidebar__label">Home</span>
#> </button>
#> </li>
#> </ul>
#> </div>
#> </div>
#> </aside>
#> <main class="shad-sidebar-layout__main">
#> <div>
#> <button type="button" class="shad-sidebar__trigger" aria-label="Toggle sidebar">
#> <svg class="shad-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect width="18" height="18" x="3" y="3" rx="2"/><path d="M9 3v18"/></svg>
#> </button>
#> Dashboard
#> </div>
#> </main>
#> </div>