Title: | Create Dashboards with 'Shiny' |
---|---|
Description: | Create dashboards with 'Shiny'. This package provides a theme on top of 'Shiny', making it easy to create attractive dashboards. |
Authors: | Winston Chang [aut, cre], Barbara Borges Ribeiro [aut], RStudio [cph], Almasaeed Studio [ctb, cph] (AdminLTE theme for Bootstrap), Adobe Systems Incorporated [ctb, cph] (Source Sans Pro font) |
Maintainer: | Winston Chang <[email protected]> |
License: | GPL (>= 2) | file LICENSE |
Version: | 0.7.2 |
Built: | 2024-11-01 03:54:04 UTC |
Source: | https://github.com/rstudio/shinydashboard |
Boxes can be used to hold content in the main body of a dashboard.
box( ..., title = NULL, footer = NULL, status = NULL, solidHeader = FALSE, background = NULL, width = 6, height = NULL, collapsible = FALSE, collapsed = FALSE )
box( ..., title = NULL, footer = NULL, status = NULL, solidHeader = FALSE, background = NULL, width = 6, height = NULL, collapsible = FALSE, collapsed = FALSE )
... |
Contents of the box. |
title |
Optional title. |
footer |
Optional footer text. |
status |
The status of the item This determines the item's background color. Valid statuses are listed in validStatuses. |
solidHeader |
Should the header be shown with a solid color background? |
background |
If NULL (the default), the background of the box will be white. Otherwise, a color string. Valid colors are listed in validColors. |
width |
The width of the box, using the Bootstrap grid system. This is
used for row-based layouts. The overall width of a region is 12, so the
default valueBox width of 4 occupies 1/3 of that width. For column-based
layouts, use |
height |
The height of a box, in pixels or other CSS unit. By default the height scales automatically with the content. |
collapsible |
If TRUE, display a button in the upper right that allows the user to collapse the box. |
collapsed |
If TRUE, start collapsed. This must be used with
|
Other boxes:
infoBox()
,
tabBox()
,
valueBox()
## Only run this example in interactive R sessions if (interactive()) { library(shiny) # A dashboard body with a row of infoBoxes and valueBoxes, and two rows of boxes body <- dashboardBody( # infoBoxes fluidRow( infoBox( "Orders", uiOutput("orderNum2"), "Subtitle", icon = icon("credit-card") ), infoBox( "Approval Rating", "60%", icon = icon("line-chart"), color = "green", fill = TRUE ), infoBox( "Progress", uiOutput("progress2"), icon = icon("users"), color = "purple" ) ), # valueBoxes fluidRow( valueBox( uiOutput("orderNum"), "New Orders", icon = icon("credit-card"), href = "http://google.com" ), valueBox( tagList("60", tags$sup(style="font-size: 20px", "%")), "Approval Rating", icon = icon("line-chart"), color = "green" ), valueBox( htmlOutput("progress"), "Progress", icon = icon("users"), color = "purple" ) ), # Boxes fluidRow( box(status = "primary", sliderInput("orders", "Orders", min = 1, max = 2000, value = 650), selectInput("progress", "Progress", choices = c("0%" = 0, "20%" = 20, "40%" = 40, "60%" = 60, "80%" = 80, "100%" = 100) ) ), box(title = "Histogram box title", status = "warning", solidHeader = TRUE, collapsible = TRUE, plotOutput("plot", height = 250) ) ), # Boxes with solid color, using `background` fluidRow( # Box with textOutput box( title = "Status summary", background = "green", width = 4, textOutput("status") ), # Box with HTML output, when finer control over appearance is needed box( title = "Status summary 2", width = 4, background = "red", uiOutput("status2") ), box( width = 4, background = "light-blue", p("This is content. The background color is set to light-blue") ) ) ) server <- function(input, output) { output$orderNum <- renderText({ prettyNum(input$orders, big.mark=",") }) output$orderNum2 <- renderText({ prettyNum(input$orders, big.mark=",") }) output$progress <- renderUI({ tagList(input$progress, tags$sup(style="font-size: 20px", "%")) }) output$progress2 <- renderUI({ paste0(input$progress, "%") }) output$status <- renderText({ paste0("There are ", input$orders, " orders, and so the current progress is ", input$progress, "%.") }) output$status2 <- renderUI({ iconName <- switch(input$progress, "100" = "ok", "0" = "remove", "road" ) p("Current status is: ", icon(iconName, lib = "glyphicon")) }) output$plot <- renderPlot({ hist(rnorm(input$orders)) }) } shinyApp( ui = dashboardPage( dashboardHeader(), dashboardSidebar(), body ), server = server ) }
## Only run this example in interactive R sessions if (interactive()) { library(shiny) # A dashboard body with a row of infoBoxes and valueBoxes, and two rows of boxes body <- dashboardBody( # infoBoxes fluidRow( infoBox( "Orders", uiOutput("orderNum2"), "Subtitle", icon = icon("credit-card") ), infoBox( "Approval Rating", "60%", icon = icon("line-chart"), color = "green", fill = TRUE ), infoBox( "Progress", uiOutput("progress2"), icon = icon("users"), color = "purple" ) ), # valueBoxes fluidRow( valueBox( uiOutput("orderNum"), "New Orders", icon = icon("credit-card"), href = "http://google.com" ), valueBox( tagList("60", tags$sup(style="font-size: 20px", "%")), "Approval Rating", icon = icon("line-chart"), color = "green" ), valueBox( htmlOutput("progress"), "Progress", icon = icon("users"), color = "purple" ) ), # Boxes fluidRow( box(status = "primary", sliderInput("orders", "Orders", min = 1, max = 2000, value = 650), selectInput("progress", "Progress", choices = c("0%" = 0, "20%" = 20, "40%" = 40, "60%" = 60, "80%" = 80, "100%" = 100) ) ), box(title = "Histogram box title", status = "warning", solidHeader = TRUE, collapsible = TRUE, plotOutput("plot", height = 250) ) ), # Boxes with solid color, using `background` fluidRow( # Box with textOutput box( title = "Status summary", background = "green", width = 4, textOutput("status") ), # Box with HTML output, when finer control over appearance is needed box( title = "Status summary 2", width = 4, background = "red", uiOutput("status2") ), box( width = 4, background = "light-blue", p("This is content. The background color is set to light-blue") ) ) ) server <- function(input, output) { output$orderNum <- renderText({ prettyNum(input$orders, big.mark=",") }) output$orderNum2 <- renderText({ prettyNum(input$orders, big.mark=",") }) output$progress <- renderUI({ tagList(input$progress, tags$sup(style="font-size: 20px", "%")) }) output$progress2 <- renderUI({ paste0(input$progress, "%") }) output$status <- renderText({ paste0("There are ", input$orders, " orders, and so the current progress is ", input$progress, "%.") }) output$status2 <- renderUI({ iconName <- switch(input$progress, "100" = "ok", "0" = "remove", "road" ) p("Current status is: ", icon(iconName, lib = "glyphicon")) }) output$plot <- renderPlot({ hist(rnorm(input$orders)) }) } shinyApp( ui = dashboardPage( dashboardHeader(), dashboardSidebar(), body ), server = server ) }
A dashboard header can be left blank, or it can include dropdown menu items on the right side.
dashboardHeader( ..., title = NULL, titleWidth = NULL, disable = FALSE, .list = NULL )
dashboardHeader( ..., title = NULL, titleWidth = NULL, disable = FALSE, .list = NULL )
... |
Items to put in the header. Should be |
title |
An optional title to show in the header bar.. By default, this
will also be used as the title shown in the browser's title bar. If you
want that to be different from the text in the dashboard header bar, set
the |
titleWidth |
The width of the title area. This must either be a number which specifies the width in pixels, or a string that specifies the width in CSS units. |
disable |
If |
.list |
An optional list containing items to put in the header. Same as
the |
## Only run this example in interactive R sessions if (interactive()) { library(shiny) # A dashboard header with 3 dropdown menus header <- dashboardHeader( title = "Dashboard Demo", # Dropdown menu for messages dropdownMenu(type = "messages", badgeStatus = "success", messageItem("Support Team", "This is the content of a message.", time = "5 mins" ), messageItem("Support Team", "This is the content of another message.", time = "2 hours" ), messageItem("New User", "Can I get some help?", time = "Today" ) ), # Dropdown menu for notifications dropdownMenu(type = "notifications", badgeStatus = "warning", notificationItem(icon = icon("users"), status = "info", "5 new members joined today" ), notificationItem(icon = icon("warning"), status = "danger", "Resource usage near limit." ), notificationItem(icon = icon("shopping-cart", lib = "glyphicon"), status = "success", "25 sales made" ), notificationItem(icon = icon("user", lib = "glyphicon"), status = "danger", "You changed your username" ) ), # Dropdown menu for tasks, with progress bar dropdownMenu(type = "tasks", badgeStatus = "danger", taskItem(value = 20, color = "aqua", "Refactor code" ), taskItem(value = 40, color = "green", "Design new layout" ), taskItem(value = 60, color = "yellow", "Another task" ), taskItem(value = 80, color = "red", "Write documentation" ) ) ) shinyApp( ui = dashboardPage( header, dashboardSidebar(), dashboardBody() ), server = function(input, output) { } ) }
## Only run this example in interactive R sessions if (interactive()) { library(shiny) # A dashboard header with 3 dropdown menus header <- dashboardHeader( title = "Dashboard Demo", # Dropdown menu for messages dropdownMenu(type = "messages", badgeStatus = "success", messageItem("Support Team", "This is the content of a message.", time = "5 mins" ), messageItem("Support Team", "This is the content of another message.", time = "2 hours" ), messageItem("New User", "Can I get some help?", time = "Today" ) ), # Dropdown menu for notifications dropdownMenu(type = "notifications", badgeStatus = "warning", notificationItem(icon = icon("users"), status = "info", "5 new members joined today" ), notificationItem(icon = icon("warning"), status = "danger", "Resource usage near limit." ), notificationItem(icon = icon("shopping-cart", lib = "glyphicon"), status = "success", "25 sales made" ), notificationItem(icon = icon("user", lib = "glyphicon"), status = "danger", "You changed your username" ) ), # Dropdown menu for tasks, with progress bar dropdownMenu(type = "tasks", badgeStatus = "danger", taskItem(value = 20, color = "aqua", "Refactor code" ), taskItem(value = 40, color = "green", "Design new layout" ), taskItem(value = 60, color = "yellow", "Another task" ), taskItem(value = 80, color = "red", "Write documentation" ) ) ) shinyApp( ui = dashboardPage( header, dashboardSidebar(), dashboardBody() ), server = function(input, output) { } ) }
This creates a dashboard page for use in a Shiny app.
dashboardPage( header, sidebar, body, title = NULL, skin = c("blue", "black", "purple", "green", "red", "yellow") )
dashboardPage( header, sidebar, body, title = NULL, skin = c("blue", "black", "purple", "green", "red", "yellow") )
header |
A header created by |
sidebar |
A sidebar created by |
body |
A body created by |
title |
A title to display in the browser's title bar. If no value is
provided, it will try to extract the title from the |
skin |
A color theme. One of |
dashboardHeader
, dashboardSidebar
,
dashboardBody
.
## Only run this example in interactive R sessions if (interactive()) { # Basic dashboard page template library(shiny) shinyApp( ui = dashboardPage( dashboardHeader(), dashboardSidebar(), dashboardBody(), title = "Dashboard example" ), server = function(input, output) { } ) }
## Only run this example in interactive R sessions if (interactive()) { # Basic dashboard page template library(shiny) shinyApp( ui = dashboardPage( dashboardHeader(), dashboardSidebar(), dashboardBody(), title = "Dashboard example" ), server = function(input, output) { } ) }
A dashboard sidebar typically contains a sidebarMenu
, although
it may also contain a sidebarSearchForm
, or other Shiny inputs.
dashboardSidebar(..., disable = FALSE, width = NULL, collapsed = FALSE)
dashboardSidebar(..., disable = FALSE, width = NULL, collapsed = FALSE)
... |
Items to put in the sidebar. |
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. |
collapsed |
If |
## Only run this example in interactive R sessions if (interactive()) { header <- dashboardHeader() sidebar <- dashboardSidebar( sidebarUserPanel("User Name", subtitle = a(href = "#", icon("circle", class = "text-success"), "Online"), # Image file should be in www/ subdir image = "userimage.png" ), sidebarSearchForm(label = "Enter a number", "searchText", "searchButton"), sidebarMenu( # Setting id makes input$tabs give the tabName of currently-selected tab id = "tabs", menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")), menuItem("Widgets", icon = icon("th"), tabName = "widgets", badgeLabel = "new", badgeColor = "green"), menuItem("Charts", icon = icon("bar-chart-o"), menuSubItem("Sub-item 1", tabName = "subitem1"), menuSubItem("Sub-item 2", tabName = "subitem2") ) ) ) body <- dashboardBody( tabItems( tabItem("dashboard", div(p("Dashboard tab content")) ), tabItem("widgets", "Widgets tab content" ), tabItem("subitem1", "Sub-item 1 tab content" ), tabItem("subitem2", "Sub-item 2 tab content" ) ) ) shinyApp( ui = dashboardPage(header, sidebar, body), server = function(input, output) { } ) }
## Only run this example in interactive R sessions if (interactive()) { header <- dashboardHeader() sidebar <- dashboardSidebar( sidebarUserPanel("User Name", subtitle = a(href = "#", icon("circle", class = "text-success"), "Online"), # Image file should be in www/ subdir image = "userimage.png" ), sidebarSearchForm(label = "Enter a number", "searchText", "searchButton"), sidebarMenu( # Setting id makes input$tabs give the tabName of currently-selected tab id = "tabs", menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")), menuItem("Widgets", icon = icon("th"), tabName = "widgets", badgeLabel = "new", badgeColor = "green"), menuItem("Charts", icon = icon("bar-chart-o"), menuSubItem("Sub-item 1", tabName = "subitem1"), menuSubItem("Sub-item 2", tabName = "subitem2") ) ) ) body <- dashboardBody( tabItems( tabItem("dashboard", div(p("Dashboard tab content")) ), tabItem("widgets", "Widgets tab content" ), tabItem("subitem1", "Sub-item 1 tab content" ), tabItem("subitem2", "Sub-item 2 tab content" ) ) ) shinyApp( ui = dashboardPage(header, sidebar, body), server = function(input, output) { } ) }
Create a dropdown menu to place in a dashboard header
dropdownMenu( ..., type = c("messages", "notifications", "tasks"), badgeStatus = "primary", icon = NULL, headerText = NULL, .list = NULL )
dropdownMenu( ..., type = c("messages", "notifications", "tasks"), badgeStatus = "primary", icon = NULL, headerText = NULL, .list = NULL )
... |
Items to put in the menu. Typically, message menus should contain
|
type |
The type of menu. Should be one of "messages", "notifications", "tasks". |
badgeStatus |
The status of the badge which displays the number of items
in the menu. This determines the badge's color. Valid statuses are listed
in validStatuses. A value of |
icon |
An icon to display in the header. By default, the icon is
automatically selected depending on |
headerText |
An optional text argument used for the header of the
dropdown menu (this is only visible when the menu is expanded). If none is
provided by the user, the default is "You have |
.list |
An optional list containing items to put in the menu Same as the
|
dashboardHeader
for example usage.
This is the UI-side function for creating a dynamic dropdown menu.
dropdownMenuOutput(outputId)
dropdownMenuOutput(outputId)
outputId |
Output variable name. |
renderMenu
for the corresponding server-side function
and examples, and dropdownMenu
for the corresponding function
for generating static menus.
Other menu outputs:
menuItemOutput()
,
menuOutput()
,
renderMenu()
,
sidebarMenuOutput()
An info box displays a large icon on the left side, and a title, value (usually a number), and an optional smaller subtitle on the right side. Info boxes are meant to be placed in the main body of a dashboard.
infoBox( title, value = NULL, subtitle = NULL, icon = shiny::icon("bar-chart"), color = "aqua", width = 4, href = NULL, fill = FALSE )
infoBox( title, value = NULL, subtitle = NULL, icon = shiny::icon("bar-chart"), color = "aqua", width = 4, href = NULL, fill = FALSE )
title |
Title text. |
value |
The value to display in the box. Usually a number or short text. |
subtitle |
Subtitle text (optional). |
icon |
An icon tag, created by |
color |
A color for the box. Valid colors are listed in validColors. |
width |
The width of the box, using the Bootstrap grid system. This is
used for row-based layouts. The overall width of a region is 12, so the
default valueBox width of 4 occupies 1/3 of that width. For column-based
layouts, use |
href |
An optional URL to link to. |
fill |
If |
box
for usage examples.
Other boxes:
box()
,
tabBox()
,
valueBox()
Create a message item to place in a dropdown message menu
messageItem( from, message, icon = shiny::icon("user"), time = NULL, href = NULL )
messageItem( from, message, icon = shiny::icon("user"), time = NULL, href = NULL )
from |
Who the message is from. |
message |
Text of the message. |
icon |
An icon tag, created by |
time |
String representing the time the message was sent. Any string may be used. For example, it could be a relative date/time like "5 minutes", "today", or "12:30pm yesterday", or an absolute time, like "2014-12-01 13:45". If NULL, no time will be displayed. |
href |
An optional URL to link to. |
dashboardHeader
for example usage.
Other menu items:
notificationItem()
,
taskItem()
Create a notification item to place in a dropdown notification menu
notificationItem( text, icon = shiny::icon("warning"), status = "success", href = NULL )
notificationItem( text, icon = shiny::icon("warning"), status = "success", href = NULL )
text |
The notification text. |
icon |
An icon tag, created by |
status |
The status of the item This determines the item's background color. Valid statuses are listed in validStatuses. |
href |
An optional URL to link to. |
dashboardHeader
for example usage.
Other menu items:
messageItem()
,
taskItem()
This is the server-side function for creating a dynamic dropdown menu.
renderDropdownMenu(expr, env = parent.frame(), quoted = FALSE)
renderDropdownMenu(expr, env = parent.frame(), quoted = FALSE)
expr |
An expression that returns a Shiny tag object, |
env |
The parent environment for the reactive expression. By default,
this is the calling environment, the same as when defining an ordinary
non-reactive expression. If |
quoted |
If it is |
Create dynamic menu output (server side)
renderMenu(expr, env = parent.frame(), quoted = FALSE, outputArgs = list())
renderMenu(expr, env = parent.frame(), quoted = FALSE, outputArgs = list())
expr |
An expression that returns a Shiny tag object, |
env |
The parent environment for the reactive expression. By default,
this is the calling environment, the same as when defining an ordinary
non-reactive expression. If |
quoted |
If it is |
outputArgs |
A list of arguments to be passed through to the implicit
call to |
menuOutput
for the corresponding client side function
and examples.
Other menu outputs:
dropdownMenuOutput()
,
menuItemOutput()
,
menuOutput()
,
sidebarMenuOutput()
## Only run these examples in interactive R sessions if (interactive()) { library(shiny) # ========== Dynamic sidebarMenu ========== ui <- dashboardPage( dashboardHeader(title = "Dynamic sidebar"), dashboardSidebar( sidebarMenuOutput("menu") ), dashboardBody() ) server <- function(input, output) { output$menu <- renderMenu({ sidebarMenu( menuItem("Menu item", icon = icon("calendar")) ) }) } shinyApp(ui, server) # ========== Dynamic dropdownMenu ========== # Example message data in a data frame messageData <- data.frame( from = c("Admininstrator", "New User", "Support"), message = c( "Sales are steady this month.", "How do I register?", "The new server is ready." ), stringsAsFactors = FALSE ) ui <- dashboardPage( dashboardHeader( title = "Dynamic menus", dropdownMenuOutput("messageMenu") ), dashboardSidebar(), dashboardBody( fluidRow( box( title = "Controls", sliderInput("slider", "Number of observations:", 1, 100, 50) ) ) ) ) server <- function(input, output) { output$messageMenu <- renderMenu({ # Code to generate each of the messageItems here, in a list. messageData # is a data frame with two columns, 'from' and 'message'. # Also add on slider value to the message content, so that messages update. msgs <- apply(messageData, 1, function(row) { messageItem( from = row[["from"]], message = paste(row[["message"]], input$slider) ) }) dropdownMenu(type = "messages", .list = msgs) }) } shinyApp(ui, server) }
## Only run these examples in interactive R sessions if (interactive()) { library(shiny) # ========== Dynamic sidebarMenu ========== ui <- dashboardPage( dashboardHeader(title = "Dynamic sidebar"), dashboardSidebar( sidebarMenuOutput("menu") ), dashboardBody() ) server <- function(input, output) { output$menu <- renderMenu({ sidebarMenu( menuItem("Menu item", icon = icon("calendar")) ) }) } shinyApp(ui, server) # ========== Dynamic dropdownMenu ========== # Example message data in a data frame messageData <- data.frame( from = c("Admininstrator", "New User", "Support"), message = c( "Sales are steady this month.", "How do I register?", "The new server is ready." ), stringsAsFactors = FALSE ) ui <- dashboardPage( dashboardHeader( title = "Dynamic menus", dropdownMenuOutput("messageMenu") ), dashboardSidebar(), dashboardBody( fluidRow( box( title = "Controls", sliderInput("slider", "Number of observations:", 1, 100, 50) ) ) ) ) server <- function(input, output) { output$messageMenu <- renderMenu({ # Code to generate each of the messageItems here, in a list. messageData # is a data frame with two columns, 'from' and 'message'. # Also add on slider value to the message content, so that messages update. msgs <- apply(messageData, 1, function(row) { messageItem( from = row[["from"]], message = paste(row[["message"]], input$slider) ) }) dropdownMenu(type = "messages", .list = msgs) }) } shinyApp(ui, server) }
This is the server-side function for creating a dynamic
valueBox
or infoBox
.
renderValueBox(expr, env = parent.frame(), quoted = FALSE) renderInfoBox(expr, env = parent.frame(), quoted = FALSE)
renderValueBox(expr, env = parent.frame(), quoted = FALSE) renderInfoBox(expr, env = parent.frame(), quoted = FALSE)
expr |
An expression that returns a Shiny tag object, |
env |
The parent environment for the reactive expression. By default,
this is the calling environment, the same as when defining an ordinary
non-reactive expression. If |
quoted |
If it is |
valueBoxOutput
for the corresponding UI-side function.
## Only run this example in interactive R sessions if (interactive()) { library(shiny) ui <- dashboardPage( dashboardHeader(title = "Dynamic boxes"), dashboardSidebar(), dashboardBody( fluidRow( box(width = 2, actionButton("count", "Count")), infoBoxOutput("ibox"), valueBoxOutput("vbox") ) ) ) server <- function(input, output) { output$ibox <- renderInfoBox({ infoBox( "Title", input$count, icon = icon("credit-card") ) }) output$vbox <- renderValueBox({ valueBox( "Title", input$count, icon = icon("credit-card") ) }) } shinyApp(ui, server) }
## Only run this example in interactive R sessions if (interactive()) { library(shiny) ui <- dashboardPage( dashboardHeader(title = "Dynamic boxes"), dashboardSidebar(), dashboardBody( fluidRow( box(width = 2, actionButton("count", "Count")), infoBoxOutput("ibox"), valueBoxOutput("vbox") ) ) ) server <- function(input, output) { output$ibox <- renderInfoBox({ infoBox( "Title", input$count, icon = icon("credit-card") ) }) output$vbox <- renderValueBox({ valueBox( "Title", input$count, icon = icon("credit-card") ) }) } shinyApp(ui, server) }
A dashboardSidebar
can contain a sidebarMenu
. A
sidebarMenu
contains menuItem
s, and they can in turn contain
menuSubItem
s.
sidebarMenu(..., id = NULL, .list = NULL) menuItem( text, ..., icon = NULL, badgeLabel = NULL, badgeColor = "green", tabName = NULL, href = NULL, newtab = TRUE, selected = NULL, expandedName = as.character(gsub("[[:space:]]", "", text)), startExpanded = FALSE ) menuSubItem( text, tabName = NULL, href = NULL, newtab = TRUE, icon = shiny::icon("angle-double-right"), selected = NULL )
sidebarMenu(..., id = NULL, .list = NULL) menuItem( text, ..., icon = NULL, badgeLabel = NULL, badgeColor = "green", tabName = NULL, href = NULL, newtab = TRUE, selected = NULL, expandedName = as.character(gsub("[[:space:]]", "", text)), startExpanded = FALSE ) menuSubItem( text, tabName = NULL, href = NULL, newtab = TRUE, icon = shiny::icon("angle-double-right"), selected = NULL )
... |
For menu items, this may consist of |
id |
For |
.list |
An optional list containing items to put in the menu Same as the
|
text |
Text to show for the menu item. |
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 are listed in validColors. |
tabName |
The name of a tab that this menu item will activate. Not
compatible with |
href |
An link address. Not compatible with |
newtab |
If |
selected |
If |
expandedName |
A unique name given to each |
startExpanded |
Should this |
Menu items (and similarly, sub-items) should have a value for either
href
or tabName
; otherwise the item would do nothing. If it has
a value for href
, then the item will simply be a link to that value.
If a menuItem
has a non-NULL tabName
, then the menuItem
will behave like a tab – in other words, clicking on the menuItem
will bring a corresponding tabItem
to the front, similar to a
tabPanel
. One important difference between a
menuItem
and a tabPanel
is that, for a menuItem
, you
must also supply a corresponding tabItem
with the same value for
tabName
, whereas for a tabPanel
, no tabName
is needed.
(This is because the structure of a tabPanel
is such that the tab name
can be automatically generated.) Sub-items are also able to activate
tabItem
s.
Menu items (but not sub-items) also may have an optional badge. A badge is a colored oval containing text.
dashboardSidebar
for example usage. For
dynamically-generated sidebar menus, see renderMenu
and
sidebarMenuOutput
.
Other sidebar items:
sidebarSearchForm()
,
sidebarUserPanel()
This is the UI-side function for creating a dynamic sidebar menu.
sidebarMenuOutput(outputId)
sidebarMenuOutput(outputId)
outputId |
Output variable name. |
renderMenu
for the corresponding server-side function
and examples, and sidebarMenu
for the corresponding function
for generating static sidebar menus.
Other menu outputs:
dropdownMenuOutput()
,
menuItemOutput()
,
menuOutput()
,
renderMenu()
A search form consists of a text input field and a search button.
sidebarSearchForm( textId, buttonId, label = "Search...", icon = shiny::icon("search") )
sidebarSearchForm( textId, buttonId, label = "Search...", icon = shiny::icon("search") )
textId |
Shiny input ID for the text input box. |
buttonId |
Shiny input ID for the search button (which functions like an
|
label |
Text label to display inside the search box. |
icon |
An icon tag, created by |
dashboardSidebar
for example usage.
Other sidebar items:
sidebarMenu()
,
sidebarUserPanel()
A panel displaying user information in a sidebar
sidebarUserPanel(name, subtitle = NULL, image = NULL)
sidebarUserPanel(name, subtitle = NULL, image = NULL)
name |
Name of the user. |
subtitle |
Text or HTML to be shown below the name. |
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. |
dashboardSidebar
for example usage.
Other sidebar items:
sidebarMenu()
,
sidebarSearchForm()
Create a tabbed box
tabBox( ..., id = NULL, selected = NULL, title = NULL, width = 6, height = NULL, side = c("left", "right") )
tabBox( ..., id = NULL, selected = NULL, title = NULL, width = 6, height = NULL, side = c("left", "right") )
... |
|
id |
If provided, you can use |
selected |
The |
title |
Title for the tabBox. |
width |
The width of the box, using the Bootstrap grid system. This is
used for row-based layouts. The overall width of a region is 12, so the
default valueBox width of 4 occupies 1/3 of that width. For column-based
layouts, use |
height |
The height of a box, in pixels or other CSS unit. By default the height scales automatically with the content. |
side |
Which side of the box the tabs should be on ( |
Other boxes:
box()
,
infoBox()
,
valueBox()
## Only run this example in interactive R sessions if (interactive()) { library(shiny) body <- dashboardBody( fluidRow( tabBox( title = "First tabBox", # The id lets us use input$tabset1 on the server to find the current tab id = "tabset1", height = "250px", tabPanel("Tab1", "First tab content"), tabPanel("Tab2", "Tab content 2") ), tabBox( side = "right", height = "250px", selected = "Tab3", tabPanel("Tab1", "Tab content 1"), tabPanel("Tab2", "Tab content 2"), tabPanel("Tab3", "Note that when side=right, the tab order is reversed.") ) ), fluidRow( tabBox( # Title can include an icon title = tagList(shiny::icon("gear"), "tabBox status"), tabPanel("Tab1", "Currently selected tab from first box:", verbatimTextOutput("tabset1Selected") ), tabPanel("Tab2", "Tab content 2") ) ) ) shinyApp( ui = dashboardPage(dashboardHeader(title = "tabBoxes"), dashboardSidebar(), body), server = function(input, output) { # The currently selected tab from the first box output$tabset1Selected <- renderText({ input$tabset1 }) } ) }
## Only run this example in interactive R sessions if (interactive()) { library(shiny) body <- dashboardBody( fluidRow( tabBox( title = "First tabBox", # The id lets us use input$tabset1 on the server to find the current tab id = "tabset1", height = "250px", tabPanel("Tab1", "First tab content"), tabPanel("Tab2", "Tab content 2") ), tabBox( side = "right", height = "250px", selected = "Tab3", tabPanel("Tab1", "Tab content 1"), tabPanel("Tab2", "Tab content 2"), tabPanel("Tab3", "Note that when side=right, the tab order is reversed.") ) ), fluidRow( tabBox( # Title can include an icon title = tagList(shiny::icon("gear"), "tabBox status"), tabPanel("Tab1", "Currently selected tab from first box:", verbatimTextOutput("tabset1Selected") ), tabPanel("Tab2", "Tab content 2") ) ) ) shinyApp( ui = dashboardPage(dashboardHeader(title = "tabBoxes"), dashboardSidebar(), body), server = function(input, output) { # The currently selected tab from the first box output$tabset1Selected <- renderText({ input$tabset1 }) } ) }
One tab to put inside a tab items container
tabItem(tabName = NULL, ...)
tabItem(tabName = NULL, ...)
tabName |
The name of a tab. This must correspond to the |
... |
Contents of the tab. |
menuItem
, menuSubItem
,
tabItems
. See sidebarMenu
for a usage example.
A container for tab items
tabItems(...)
tabItems(...)
... |
Items to put in the container. Each item should be a
|
menuItem
, menuSubItem
,
tabItem
. See sidebarMenu
for a usage example.
Create a task item to place in a dropdown task menu
taskItem(text, value = 0, color = "aqua", href = NULL)
taskItem(text, value = 0, color = "aqua", href = NULL)
text |
The task text. |
value |
A percent value to use for the bar. |
color |
A color for the bar. Valid colors are listed in validColors. |
href |
An optional URL to link to. |
dashboardHeader
for example usage.
Other menu items:
messageItem()
,
notificationItem()
This function controls the active tab of tabItems
from the
server. It behaves just like updateTabsetPanel
.
updateTabItems(session = getDefaultReactiveDomain(), inputId, selected = NULL)
updateTabItems(session = getDefaultReactiveDomain(), inputId, selected = NULL)
session |
The |
inputId |
The id of the |
selected |
The |
## Only run this example in interactive R sessions if (interactive()) { ui <- dashboardPage( dashboardHeader(title = "Simple tabs"), dashboardSidebar( sidebarMenu( id = "tabs", menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")), menuItem("Widgets", tabName = "widgets", icon = icon("th")) ), actionButton('switchtab', 'Switch tab') ), dashboardBody( tabItems( tabItem(tabName = "dashboard", h2("Dashboard tab content") ), tabItem(tabName = "widgets", h2("Widgets tab content") ) ) ) ) server <- function(input, output, session) { observeEvent(input$switchtab, { newtab <- switch(input$tabs, "dashboard" = "widgets", "widgets" = "dashboard" ) updateTabItems(session, "tabs", newtab) }) } shinyApp(ui, server) }
## Only run this example in interactive R sessions if (interactive()) { ui <- dashboardPage( dashboardHeader(title = "Simple tabs"), dashboardSidebar( sidebarMenu( id = "tabs", menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")), menuItem("Widgets", tabName = "widgets", icon = icon("th")) ), actionButton('switchtab', 'Switch tab') ), dashboardBody( tabItems( tabItem(tabName = "dashboard", h2("Dashboard tab content") ), tabItem(tabName = "widgets", h2("Widgets tab content") ) ) ) ) server <- function(input, output, session) { observeEvent(input$switchtab, { newtab <- switch(input$tabs, "dashboard" = "widgets", "widgets" = "dashboard" ) updateTabItems(session, "tabs", newtab) }) } shinyApp(ui, server) }
A value box displays a value (usually a number) in large text, with a smaller subtitle beneath, and a large icon on the right side. Value boxes are meant to be placed in the main body of a dashboard.
valueBox(value, subtitle, icon = NULL, color = "aqua", width = 4, href = NULL)
valueBox(value, subtitle, icon = NULL, color = "aqua", width = 4, href = NULL)
value |
The value to display in the box. Usually a number or short text. |
subtitle |
Subtitle text. |
icon |
An icon tag, created by |
color |
A color for the box. Valid colors are listed in validColors. |
width |
The width of the box, using the Bootstrap grid system. This is
used for row-based layouts. The overall width of a region is 12, so the
default valueBox width of 4 occupies 1/3 of that width. For column-based
layouts, use |
href |
An optional URL to link to. |
box
for usage examples.
Other boxes:
box()
,
infoBox()
,
tabBox()
This is the UI-side function for creating a dynamic valueBox
or
infoBox
.
valueBoxOutput(outputId, width = 4) infoBoxOutput(outputId, width = 4)
valueBoxOutput(outputId, width = 4) infoBoxOutput(outputId, width = 4)
outputId |
Output variable name. |
width |
The width of the box, using the Bootstrap grid system. This is
used for row-based layouts. The overall width of a region is 12, so the
default valueBox width of 4 occupies 1/3 of that width. For column-based
layouts, use |
renderValueBox
for the corresponding server-side
function and examples.