modal: Modal

modalR Documentation

Description

Create a modal in the UI. The modal is not down see modal_show(), or modal_toggle() (from server).

Usage

modal(
  id,
  ...,
  static_backdrop = FALSE,
  scrollable = FALSE,
  centered = FALSE,
  size = c("default", "sm", "lg", "xl", "fullscreen", "fullscreen-sm-down",
    "fullscreen-md-down", "fullscreen-lg-down", "fullscreen-xl-down",
    "fullscreen-xxl-down")
)

Arguments

id

ID of modal.

...

Content of the modal, modalBody(), modalHeader(), modalFooter().

static_backdrop

When backdrop is set to static, the modal will not close when clicking outside it.

scrollable

Whether to make the content scrollable.

centered

Whether to make the content vertically centered.

size

Size of the modal.

Examples

library(shiny)

ui <- fluidPage(
  theme = bslib::bs_theme(version = 5L),
  actionButton("show", "Show modal"),
  modal(
    id = "modal",
    modalHeader(
      modalTitle("Title")
    ),
    modalBody(
      p("The content of the modal")
    ),
    modalFooter(
      p("The footer of the modal")
    )
  )
)

server <- \(input, output, session){
  observeEvent(input$show, {
    modal_show("modal")
  })
}

if(interactive())
 shinyApp(ui, server)


JohnCoene/bsutils documentation built on June 15, 2024, 3:21 a.m.