bs_modal {bsplus} | R Documentation |
Modal window
Description
Modal windows are useful to make detailed explanations, and are typically attached to buttons or links. Thus, there are two parts to this system:
Usage
bs_modal(
id,
title,
body,
footer = bs_modal_closebutton(label = "Close"),
size = c("medium", "large", "small")
)
bs_modal_closebutton(label = "Close", title)
bs_attach_modal(tag, id_modal)
Arguments
id |
character, unique id for the modal window |
title |
character, title for the modal window (this argument is deprecated
for |
body |
character (HTML) or |
footer |
character (HTML) or |
size |
character, size of the modal window |
label |
character (HTML), label for the close-button |
tag |
|
id_modal |
character, unique id of modal window to attach |
Details
A modal window, created using
bs_modal()
At least one button or link to which the
id
of the modal window is attached, usingbs_attach_modal()
The verb attach is used to signify that we are attaching the id
of our
modal window to the tag
in question (generally a button or a link). This implies that
you can attach the id
of a modal window to more than one button or link.
It is your responsibility to ensure that id
is unique
among HTML elements in your page. If you have non-unique id
's, strange things may
happen to your page.
Your code may be cleaner if you can import the content for the modal body from
an external source. Here, the function shiny::[includeMarkdown][shiny::includeMarkdown]
be useful.
If you want to compose your own footer for the modal window, the function
bs_modal_closebutton()
can be useful.
Value
bs_modal()
htmltools::[tag][htmltools::tag]
,<div/>
bs_attach_modal()
htmltools::[tag][htmltools::tag]
, modified copy oftag
bs_modal_closebutton()
htmltools::[tag][htmltools::tag]
,<button/>
See Also
shiny::[includeMarkdown][shiny::includeMarkdown]
Examples
library("htmltools") # also needs `markdown` package
library("shiny")
bs_modal(id = "modal", title = "I'm a modal", body = "Yes, I am.")
bs_button("Click for modal") %>%
bs_attach_modal(id_modal = "modal")
bs_modal(
id = "modal_large",
title = "I'm a modal",
size = "large",
body = includeMarkdown(system.file("markdown", "modal.md", package = "bsplus"))
)
bs_button("Click for modal") %>%
bs_attach_modal(id_modal = "modal_large")