bs_modal | R Documentation |
Modal windows are useful to make detailed explanations, and are typically attached to buttons or links. Thus, there are two parts to this system:
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)
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 |
A modal window, created using bs_modal()
At least one button or link to which the id
of the
modal window is attached, using bs_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.
bs_modal()
htmltools::[tag][htmltools::tag]
, <div/>
bs_attach_modal()
htmltools::[tag][htmltools::tag]
,
modified copy of tag
bs_modal_closebutton()
htmltools::[tag][htmltools::tag]
, <button/>
shiny::[includeMarkdown][shiny::includeMarkdown]
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.