Using bslib
, I want the checkbox buttons here to overflow to the next line when the width of the page is too small. How can this be accomplished?
PS: Is this best accomplished using CSS?
Here is the app code:
library(shiny)
library(shinyWidgets)
library(bslib)
library(htmltools)
ui <- page_fluid(
title = "App",
bslib::accordion(
accordion_panel(
id = "panel1",
title = "panel 1",
htmltools::div(
checkboxGroupButtons(
inputId = "edit_selection",
label = "List of variables",
choices = c("NULL")
)
)
),
accordion_panel(
id = "panel2",
title = "panel 2"
)
)
)
server <- function(input, output, session) {
test_data <- c(
"Long Variable One", "Long Variable Two", "Long Variable Three", "Long Variable Four", "Long Variable Five",
"Long Variable Six", "Long Variable Seven", "Long Variable Eight", "Long Variable Nine", "Long Variable Ten",
"Long Variable Eleven", "long Variable Twelve"
)
observeEvent(test_data, {
updateCheckboxGroupButtons(
session,
inputId = "edit_selection",
choices = test_data
)
})
}
shinyApp(ui, server)
2
Answers
Yes it’s a task for css. Add this to your UI (under title):
You could use this
css
:Line break if the space is not enough:
If you would like to have a fixed with of the buttons:
Exact vertical alignment of the button rows: