2

I'm looking to shift from {shinydashboard} and {bs4Dash} towards {bslib} while keeping the nice feature of having a global collapsible sidebar in my apps.

In this {bslib} vignette some functions such as layout_sidebar() or page_navbar() are used as examples but I cannot find the first function in my latest version of {bslib} (0.4.2) nor can I find the sidebar argument in the page_navbar() function (same for sidebar() function).

There must be a simple explanation, but I can't figure why. Is the vignette outdated and these functions have been dropped ?

I tried installing directly from the github repo (rstudio/bslib), but the issue is the same.

More generally, is this possible to use exclusively {shiny} and {bslib} without additional Javascript to leverage a collapsible global sidebar as it could be done in {bs4Dash} using bs4Dash::dashboardSidebar() ?

I love the possibilities offered by {bslib} (fine tuning with bootstrap 5 and bs_add_variables()) and would appreciate a clean solution for sidebars. If this doesn't exist, does anyone knows when it will be available ?

Many thanks !

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Michaël Weber
  • 136
  • 1
  • 8

1 Answers1

2

You can install the development version of bslib:

remotes::install_github("rstudio/bslib")

Then an example is:

library(shiny)
library(bslib)
library(ggplot2)

ui <- page_navbar(
  nav(
    "Plot",
    plotOutput("gg")
  ),
  sidebar = sidebar(
    numericInput("test", "Test", value = 5)
  )
)

server <- function(input, output, session) {
  output[["gg"]] <- renderPlot({
    ggplot(
      iris, aes(x = Sepal.Length, y = Sepal.Width)
    ) + geom_point()    
  })
}

shinyApp(ui, server)
Stéphane Laurent
  • 75,186
  • 15
  • 119
  • 225