This is a simple example of resizing {bslib} cards for a dashboard. A card can be made resizable (vertical, horizontal or both) by using the resize
property. In order to use this in a {bslib} dashboard it can be added using tags$style
or included in bs_theme()
. Adding the resize-vertical
class adds a resize anchor to the botton right of a card.
library(bslib)
library(shiny)
<- page_fillable(
ui $head(
tags$style("
tags .resize-vertical {
resize: vertical;
}
")
),layout_sidebar(
sidebar = sidebar(
width = 250,
h3("controls")
),card(
card_title("Card 1"),
height = "60%",
fill = FALSE,
class = 'resize-vertical',
card_body(
plotOutput('plt')
)
),layout_column_wrap(
card(
card_title("Card 2"),
card_body(
)
),card(
card_title("Card 3"),
card_body()
)
)
)
)
<- function(input, output, session) {
server $plt <- renderPlot({
outputplot(mtcars$mpg, mtcars$hp)
})$data <- renderDataTable(mtcars)
output
}
shinyApp(ui, server)