R/Shiny/bs4Dashの基礎⑨


横並びのCardを実装

fluidRow()の中で各bs4Card()のwidthの合計が12になるように実装。

library(shiny)
library(bs4Dash)

ui <- bs4DashPage(
  navbar = bs4DashNavbar(),
  sidebar = bs4DashSidebar(),
  body = bs4DashBody(
    fluidRow(
      bs4Card(
        plotOutput(outputId = "a"),
        inputId = "a",
        title = "a",
        status = "primary",
        width = 3
      ),
      bs4Card(
        plotOutput(outputId = "b"),
        inputId = "b",
        title = "b",
        status = "warning",
        width = 5
      ),
      bs4Card(
        plotOutput(outputId = "c"),
        inputId = "c",
        title = "c",
        status = "secondary",
        width = 4
      )
    )
  ),
  controlbar = bs4DashControlbar(),
  footer = bs4DashFooter(),
  title = "yono2844"
)

server <- function(input, output, session) {
  output$a <- renderPlot(expr = {
    hist(iris$Sepal.Length)
  })
  output$b <- renderPlot(expr = {
    hist(iris$Sepal.Width)
  })
  output$c <- renderPlot(expr = {
    hist(iris$Petal.Length)
  })
}

shinyApp(ui = ui, server = server)