bs4DashSidebar | R Documentation |
dashboardSidebar creates an adminLTE3 dashboard main sidebar to insert in the sidebar slot of dashboardPage.
updateSidebar toggles a dashboardSidebar on the client.
sidebarMenu creates a menu for dashboardSidebar.
menuItem creates an item to put in sidebarMenu.
menuSubItem creates an item to put in menuItem.
sidebarHeader creates a header to put in dashboardSidebar.
sidebarUserPanel creates a user Panel to put in dashboardSidebar.
updateTabItems controls the active tab of tabItems
from the
server. It behaves just like updateTabsetPanel
.
bs4DashSidebar( ..., disable = FALSE, width = NULL, skin = "dark", status = "primary", elevation = 4, collapsed = FALSE, minified = TRUE, expandOnHover = TRUE, fixed = TRUE, id = NULL, customArea = NULL ) updatebs4Sidebar(id, session = shiny::getDefaultReactiveDomain()) bs4SidebarMenu( ..., id = NULL, .list = NULL, flat = FALSE, compact = FALSE, childIndent = TRUE, legacy = FALSE ) bs4SidebarMenuItem( text, ..., icon = NULL, badgeLabel = NULL, badgeColor = "success", tabName = NULL, href = NULL, newTab = TRUE, selected = NULL, expandedName = as.character(gsub("[[:space:]]", "", text)), startExpanded = FALSE, condition = NULL ) bs4SidebarMenuSubItem( text, tabName = NULL, href = NULL, newTab = NULL, icon = shiny::icon("angle-double-right"), selected = NULL ) bs4SidebarHeader(title) bs4SidebarUserPanel(name, image = NULL) updatebs4TabItems( session = shiny::getDefaultReactiveDomain(), inputId, selected = NULL ) dashboardSidebar( ..., disable = FALSE, width = NULL, skin = "dark", status = "primary", elevation = 4, collapsed = FALSE, minified = TRUE, expandOnHover = TRUE, fixed = TRUE, id = NULL, customArea = NULL ) updateSidebar(id, session = shiny::getDefaultReactiveDomain()) sidebarHeader(title) sidebarMenu( ..., id = NULL, .list = NULL, flat = FALSE, compact = FALSE, childIndent = TRUE, legacy = FALSE ) sidebarUserPanel(name, image = NULL) menuItem( text, ..., icon = NULL, badgeLabel = NULL, badgeColor = "success", tabName = NULL, href = NULL, newTab = TRUE, selected = NULL, expandedName = as.character(gsub("[[:space:]]", "", text)), startExpanded = FALSE, condition = NULL ) menuSubItem( text, tabName = NULL, href = NULL, newTab = NULL, icon = shiny::icon("angle-double-right"), selected = NULL ) updateTabItems( session = shiny::getDefaultReactiveDomain(), inputId, selected = NULL )
... |
menuSubItem. |
disable |
If |
width |
The width of the sidebar. This must either be a number which specifies the width in pixels, or a string that specifies the width in CSS units. |
skin |
Sidebar skin. "dark" or "light". |
status |
Sidebar status. Valid statuses are defined as follows:
|
elevation |
Sidebar elevation. 4 by default (until 5). |
collapsed |
If |
minified |
Whether to slightly close the sidebar but still show item icons. Default to TRUE. |
expandOnHover |
Whether to expand the sidebar om hover. TRUE by default. |
fixed |
Whether to fix the sidebar. Default to TRUE. |
id |
For sidebarMenu, if |
customArea |
Sidebar bottom space area. Only works if sidebar is fixed. |
session |
Shiny session object. |
.list |
An optional list containing items to put in the menu Same as the
|
flat |
Whether sidebar items should have a flat design. FALSE by default. |
compact |
Whether items should be compacted. FALSE by default. |
childIndent |
Whether to indent children. TRUE by default. |
legacy |
Whether to use the old adminLTE2 item selection display. Default to FALSE. |
text |
Item name. |
icon |
An icon tag, created by |
badgeLabel |
A label for an optional badge. Usually a number or a short word like "new". |
badgeColor |
A color for the badge. Valid colors:
|
tabName |
Should correspond exactly to the tabName given in |
href |
An link address. Not compatible with |
newTab |
If |
selected |
If |
expandedName |
A unique name given to each |
startExpanded |
Whether to expand the menuItem at start. |
condition |
When using menuItem with conditionalPanel, write the condition here (see https://github.com/RinteRface/bs4Dash/issues/35). |
title |
title. |
name |
Name of the user. |
image |
A filename or URL to use for an image of the person. If it is a local file, the image should be contained under the www/ subdirectory of the application. |
inputId |
The id of the |
See examples for a use case of the condition parameter.
David Granjon, dgranjon@ymail.com
dashboardBody
if (interactive()) { library(shiny) library(bs4Dash) shinyApp( ui = dashboardPage( header = dashboardHeader(), sidebar = dashboardSidebar(id = "sidebar"), body = dashboardBody( actionButton(inputId = "sidebarToggle", label = "Toggle Sidebar") ) ), server = function(input, output, session) { observeEvent(input$sidebar, { if (input$sidebar) { showModal(modalDialog( title = "Alert", "The sidebar is opened.", easyClose = TRUE, footer = NULL )) } }) observeEvent(input$sidebarToggle, { updateSidebar(id = "sidebar", session = session) }) observe({ print(input$sidebar) }) } ) } if (interactive()) { # sidebarItem with conditional value library(shiny) library(bs4Dash) ui <- dashboardPage( dashboardHeader(), dashboardSidebar( sidebarMenu( id = "sidebarMenu", menuItem( text = "Tab 1", tabName = "tab1" ), menuItem( condition = "input.show == true", text = "Tab 2", tabName = "tab2" ) ) ), dashboardBody( tabItems( tabItem( tabName = "tab1", h1("Welcome!"), checkboxInput("show", "Show Tab 2", FALSE) ), tabItem( tabName = "tab2", h1("Hey! You found me!") ) ) ) ) server <- function(input, output) {} shinyApp(ui = ui, server = server) } ## Only run this example in interactive R sessions if (interactive()) { library(shiny) library(bs4Dash) shinyApp( ui = dashboardPage( header = dashboardHeader(skin = "dark"), body = dashboardBody( tabItems( tabItem( tabName = "tab1", sliderInput("obs", "Number of observations:", min = 0, max = 1000, value = 500 ), plotOutput("distPlot") ), tabItem( tabName = "tab2", checkboxGroupInput( "variable", "Variables to show:", c( "Cylinders" = "cyl", "Transmission" = "am", "Gears" = "gear" ) ), tableOutput("data") ), tabItem( tabName = "tab3", checkboxInput("val", "Some value", FALSE), textOutput("value") ), tabItem( tabName = "tab4", "Nothing special here!" ), tabItem( tabName = "tab5", "Tab 5" ), tabItem( tabName = "tab6", "Tab 6" ), tabItem( tabName = "tab7", "Tab 7" ) ) ), sidebar = dashboardSidebar( skin = "light", inputId = "sidebarState", sidebarMenu( id = "sidebar", menuItem( text = "Tab 1", tabName = "tab1", icon = icon("shuttle-van") ), menuItem( text = "Tab 2", tabName = "tab2", icon = icon("space-shuttle"), selected = TRUE ), menuItem( text = "Item List 1", icon = icon("bars"), startExpanded = TRUE, menuSubItem( text = "Item 3", tabName = "tab3", icon = icon("circle-thin") ), menuSubItem( text = "Item 4", tabName = "tab4", icon = icon("circle-thin") ) ), menuItem( text = "Item List 2", icon = icon("bars"), startExpanded = FALSE, menuSubItem( text = "Item 5", tabName = "tab5", icon = icon("circle-thin") ), menuSubItem( text = "Item 6", tabName = "tab6", icon = icon("circle-thin") ) ), menuItem( text = "Tab 7", tabName = "tab7", icon = icon("home") ) ) ), controlbar = dashboardControlbar( skin = "light", sliderInput( inputId = "controller", label = "Update the first tabset", min = 1, max = 6, value = 2 ) ), footer = bs4DashFooter() ), server = function(input, output, session) { observe(print(input$sidebarItemExpanded)) observe(print(input$sidebar)) # update tabset1 observeEvent(input$controller, { updateTabItems( session, inputId = "sidebar", selected = paste0("tab", input$controller) ) }, ignoreInit = TRUE ) output$distPlot <- renderPlot({ hist(rnorm(input$obs)) }) output$data <- renderTable( { mtcars[, c("mpg", input$variable), drop = FALSE] }, rownames = TRUE ) output$value <- renderText({ input$val }) } ) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.