Bootstrap 4 shinydashboard using AdminLTE3
Taking the simple shinydashboard example:
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(title = "Basic dashboard"),
dashboardSidebar(),
dashboardBody(
# Boxes need to be put in a row (or column)
fluidRow(
box(plotOutput("plot1", height = 250)),
box(
title = "Controls",
sliderInput("slider", "Number of observations:", 1, 100, 50)
)
)
)
)
server <- function(input, output) {
set.seed(122)
histdata <- rnorm(500)
output$plot1 <- renderPlot({
data <- histdata[seq_len(input$slider)]
hist(data)
})
}
shinyApp(ui, server)
Starting from v2.0.0, moving to bs4Dash is rather simple:
library(bs4Dash)
ui <- dashboardPage(
dashboardHeader(title = "Basic dashboard"),
dashboardSidebar(),
dashboardBody(
# Boxes need to be put in a row (or column)
fluidRow(
box(plotOutput("plot1", height = 250)),
box(
title = "Controls",
sliderInput("slider", "Number of observations:", 1, 100, 50)
)
)
)
)
server <- function(input, output) {
set.seed(122)
histdata <- rnorm(500)
output$plot1 <- renderPlot({
data <- histdata[seq_len(input$slider)]
hist(data)
})
}
shinyApp(ui, server)
bs4Dash is undergoing major rework to make it easier to come from shinydashboard. The current development version 2.0.0 provides a 1:1 supports, in other word moving from shinydashboard to bs4Dash is accomplished by changing library(shinydashboard)
to library(bs4Dash)
.
bs4Dash v2.0.0 also provides 1:1 with shinydashboardPlus to ease compatibility.
Apps built with bs4Dash version <= 0.5.0 are definitely not compatible with v2.0.0 due to substantial breaking changes in the API. We advise users to keep the old version for old apps and move to to the new version for newer apps.
# latest devel version
devtools::install_github("RinteRface/bs4Dash")
# from CRAN
install.packages("bs4Dash")
See a working example on shinyapps.io here. You may also run:
Issues are listed here.
I warmly thank Glyphicons creator for providing them for free with Bootstrap.
Please note that the bs4Dash project is released with a Contributor Code of Conduct. By contributing to this project, you agree toabide by its terms.