Make sidebar resizeable #1268
-
|
How to make the sidebar width be adjustable by the user? I have this dummy app to play with. Click for full codelibrary(shiny)
library(bslib)
ui <- page_sidebar(
title = "Histogram demo",
sidebar = sidebar(
sliderInput(
"n",
"Number of observations",
min = 10,
max = 1000,
value = 100,
step = 10
)
),
fillable = TRUE,
plotOutput("hist")
)
server <- function(input, output, session) {
output$hist <- renderPlot({
hist(
rnorm(input$n),
col = "#1f76b4",
border = "white",
main = NULL,
xlab = "Value"
)
})
}
shinyApp(ui, server)I have added one line of css which looks like it could work. Click for full codelibrary(shiny)
library(bslib)
ui <- page_sidebar(
title = "Histogram demo",
tags$style(".sidebar { resize: horizontal; }"),
sidebar = sidebar(
sliderInput(
"n",
"Number of observations",
min = 10,
max = 1000,
value = 100,
step = 10
)
),
fillable = TRUE,
plotOutput("hist")
)
server <- function(input, output, session) {
output$hist <- renderPlot({
hist(
rnorm(input$n),
col = "#1f76b4",
border = "white",
main = NULL,
xlab = "Value"
)
})
}
shinyApp(ui, server)But not really. The sidebar is technically resizeable, but the content on the right doesn't resize and the collapse button is fixed as well. resize.movWhat is the best way to do this? Personally, I think the ability to adjust the sidebar width by the user should be the default. This should give the user more flexibility. Session |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Good news! I implemented this feature earlier this year and it'll be in the next bslib release. Try using bslib from GitHub and sidebars are all resizable by default. (#1217) |
Beta Was this translation helpful? Give feedback.

Good news! I implemented this feature earlier this year and it'll be in the next bslib release. Try using bslib from GitHub and sidebars are all resizable by default. (#1217)