Creates an off-canvas element, which is a sliding panel that appears from the edges of the viewport. This is a wrapper for Bootstrap's off-canvas component.
Usage
off_canvas(
id,
title,
...,
width = "w-25",
position = c("start", "top", "bottom", "end")
)
Arguments
- id
Character string. The ID of the off-canvas element. This ID is used to show/hide the element via JavaScript.
- title
Character string. The title to display in the header of the off-canvas element.
- ...
Additional UI elements to include in the body of the off-canvas element.
- width
Character string. Bootstrap width class to apply to the off-canvas element. Defaults to "w-100" (100% width). Common values include "w-75", "w-50", etc.
- position
Character string. The position from which the off-canvas element should appear. Must be one of "start" (left), "end" (right), "top", or "bottom". Defaults to "start".
Examples
if (interactive()) {
library(shiny)
library(bslib)
ui <- page_fillable(
actionButton(
"toggle",
"Toggle offcanvas",
`data-bs-toggle` = "offcanvas",
`data-bs-target` = "#demo",
`aria-controls` = "demo"
),
off_canvas(
id = "demo",
title = "Settings",
position = "end",
sliderInput("n", "Number", 1, 100, 50)
)
)
server <- function(input, output) {}
shinyApp(ui, server)
}