View source: R/modal-functionality.R
twBtnOpenModal | R Documentation |
Creates a button to open a Modal Dialog
twBtnOpenModal(
btn_id,
btn_label,
btn_class = NULL,
icon = NULL,
modal_id = "shiny-modal"
)
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 |
a list with a shiny.tag
class
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()) shinyApp(ui, server)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.