twBtnOpenModal {shiny.tailwind}R Documentation

Creates a button to open a Modal Dialog

Description

Creates a button to open a Modal Dialog

Usage

twBtnOpenModal(
  btn_id,
  btn_label,
  btn_class = NULL,
  icon = NULL,
  modal_id = "shiny-modal"
)

Arguments

btn_id

ID of the button

btn_label

Label for the button

btn_class

Classes to style the button

icon

an optional icon for the button

modal_id

ID of the modal, make sure that the IDs are identical to the one used in twModalDialog()

Value

a list with a shiny.tag class

Examples

ui <- div(
  use_tailwind(),
  class = "h-screen bg-stone-100 p-10",
  twBtnOpenModal(
    "open_modal", "Show Modal",
    btn_class = "px-5 py-2 bg-rose-500 hover:bg-rose-700 text-white cursor-pointer rounded-md"
  ),
  twModalDialog(p("Hello World"), )
)

server <- function(input, output, session) {
  observeEvent(input$open_modal, {
    print("Modal Opened")
  })
  observeEvent(input$submit, {
    print("Modal Closed - Submitted")
  })
  observeEvent(input$close, {
    print("Modal Closed - Closed")
  })
}
if (interactive() == TRUE) shinyApp(ui, server)

[Package shiny.tailwind version 0.2.2 Index]