I tweaked the example code in the bslib::accordion help to generate a sidebar with accordions as desired (which at the same time can be nested in levels):
Here“s the code:
library(bslib)
items <- lapply(LETTERS[1:5], function(x) {
accordion_panel(paste("Section", x),
# p() is useful to display different elements in separate lines
p(paste("Some narrative for section ",x),style = "padding-left: 20px;"),
p(paste("More narrative for section ",x),style = "padding-left: 20px;"),
accordion_panel(paste("SubSection ", x),
p(actionLink(inputId=x,label=paste0("This is ",x)),
style = "padding-left: 20px;")))
})
library(shiny)
ui <- page_fluid(
page_sidebar(
sidebar = sidebar(
accordion(!!!items,
id = "acc",
open = F))
))
server <- function(input, output) {}
shinyApp(ui, server)