Repository navigation
Make sidebar resizeable #1268
Answered
by
gadenbuie
royfrancis
asked this question in
Q&A
|
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 |
Answered by
gadenbuie
Dec 12, 2025
Replies: 2 comments 3 replies
|
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) |
3 replies
Answer selected by
royfrancis
|
Found working fix: .bslib-sidebar-resize-handle {
display: none !important;
}For example: library(shiny)
library(bslib)
ui <- page_sidebar(
title = "test dashboard",
sidebar = sidebar(
open = "always",
actionButton("push", "push me")
),
textOutput("text"),
tags$head(
tags$style(HTML("
.bslib-sidebar-resize-handle {
display: none !important;
}
"))
)
)
server <- function(input, output) {
n <- reactiveVal(0)
observeEvent(input$push, n(n() + 1))
output$text <- renderText(sprintf("hello world %d", n()))
}
shinyApp(ui, server) |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to 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)