bs_modal {bsTools} | R Documentation |
Create a Bootstrap modal
Description
Learn more at https://getbootstrap.com/docs/5.1/components/modal/.
Usage
bs_modal(
id,
header = button(attr = c(type = "button", class = "btn-close", `data-bs-dismiss` =
"modal", `aria-label` = "Close")),
title = h5("Note"),
body,
footer = button(attr = c(type = "button", class = "btn btn-secondary",
`data-bs-dismiss` = "modal"), "Close"),
modal_attr = c(class = "modal", tabindex = "-1"),
dialog_attr = c(class = "modal-dialog"),
content_attr = c(class = "modal-content"),
header_attr = c(class = "modal-header"),
title_attr = c(class = "modal-title"),
body_attr = c(class = "modal-body"),
footer_attr = c(class = "modal-footer")
)
Arguments
id |
A string, an id for the modal (to launch the modal, reference this id in the data-bs-target attribute of the HTML element that will launch the modal. See example below). |
header |
A string, likely HTML, that goes in the header div after the title. |
title |
A string, likely HTML, displayed as the title of the modal. |
body |
A string, likely HTML, displayed as the body of the modal. |
footer |
A string, likely HTML, displayed at the bottom of the modal. |
modal_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the the div wrapping the dialog. |
dialog_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the the div wrapping the content wrapper. |
content_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the the div wrapping the content (header, body, footer). |
header_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the the div wrapping the header. |
title_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the the div wrapping the title. |
body_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the div wrapping the body. |
footer_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the div wrapping the footer. |
Value
A string of HTML.
Examples
div(
button(
attr = c(
"type" = "button",
"class" = "btn btn-primary",
"data-bs-toggle" = "modal",
"data-bs-target" = "#modal1"
),
"Launch Modal"
),
bs_modal(
id = "modal1",
body = p("Here is the modal.")
)
)