Contrary to modalDialog the function allows to define modal in UI application structure. The modal can be opened with `modalButtonUI` placed anywhere in the application.

modalDialogUI(
  modalId,
  ...,
  button = modalButtonUI(modalId, "Open Modal"),
  title = NULL,
  footer = shiny::modalButton("Dismiss"),
  size = c("m", "s", "l", "xl"),
  easyClose = FALSE,
  fade = TRUE,
  backdrop = TRUE
)

modalButtonUI(modalId, label, icon = NULL, width = NULL, ...)

Arguments

modalId

Id of the modal.

...

Additional properties added to button.

button

Visible button placed in modal DOM structure, responsible for opening it. Set `NULL` to have no button included.

title

An optional title for the modal dialog.

footer

UI for modal dialog footer.

size

of the modal dialog. Can be "s", "m" (default), "l" or "xl".

easyClose

Set `TRUE` to enable closing modal with clicking outside it.

fade

Should fade-in animation be turned on?

backdrop

Set `FALSE` to turn on background covering area outside modal dialog.

label

Modal button label.

icon

Modal button icon.

width

Button width.

Value

Nested list of `shiny.tag` objects defining html structure of modal dialog, or single `shiny.tag` object in case of using `modalButtonUI` method.

Examples

if (interactive()) {
  library(shiny)
  shinyApp(
    ui = fluidPage(
      modalDialogUI("mdl", "Hello")
    ),
    server = function(input, output, session) {}
  )

  library(shiny)
  shinyApp(
    ui = fluidPage(
      modalDialogUI("mdl", "Hello", button = NULL),
      hr(),
      modalButtonUI("mdl", "Open Modal From Here")
    ),
    server = function(input, output, session) {}
  )
}