Title: | Create HTML Content with Bootstrap 5 Classes and Layouts |
---|---|
Description: | Functions are pre-configured to utilize Bootstrap 5 classes and HTML structures to create Bootstrap-styled HTML quickly and easily. Includes functions for creating common Bootstrap elements such as containers, rows, cols, navbars, etc. Intended to be used with the html5 package. Learn more at <https://getbootstrap.com/>. |
Authors: | Timothy Conwell |
Maintainer: | Timothy Conwell <[email protected]> |
License: | GPL (>= 3) |
Version: | 1.0.5 |
Built: | 2025-02-13 02:40:10 UTC |
Source: | https://github.com/tconwell/bstools |
Learn more at https://getbootstrap.com/docs/5.1/components/accordion/.
bs_accordion( id, items = list(), expand = c(), button_background_color = NULL, button_text_color = NULL, accordion_attr = list(class = "accordion"), item_attr = list(class = "accordion-item"), item_header_attr = list(class = "accordion-header"), button_attr = list(class = "accordion-button collapsed"), div_attr = list(class = "accordion-collapse collapse"), body_attr = list(class = "accordion-body") )
bs_accordion( id, items = list(), expand = c(), button_background_color = NULL, button_text_color = NULL, accordion_attr = list(class = "accordion"), item_attr = list(class = "accordion-item"), item_header_attr = list(class = "accordion-header"), button_attr = list(class = "accordion-button collapsed"), div_attr = list(class = "accordion-collapse collapse"), body_attr = list(class = "accordion-body") )
id |
A string, the id to use for the accordion, must be unique within a page (if you have multiple accordions on a page). |
items |
A named list, names become the label for each panel, values should be the HTML content to display when the panel is toggled. |
expand |
A vector, the names or positions of panels that should be expanded by default. |
button_background_color |
A string vector, the color to apply to the background of the accordion toggle button. Recycles for each panel. |
button_text_color |
A string vector, the color to apply to the text of the accordion toggle button. Recycles for each panel. |
accordion_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the div wrapping the accordion content. |
item_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the div wrapping the accordion items. |
item_header_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the accordion panel headers. |
button_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the accordion panel header button items. |
div_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the div wrapping the accordion panel content. |
body_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the div wrapping the accordion panel content body. |
A string of HTML.
bs_accordion( id = "acc1", items = list( "One" = p("Check it out."), "Two" = p("Does it work?"), "Three" = p("I hope so.") ) )
bs_accordion( id = "acc1", items = list( "One" = p("Check it out."), "Two" = p("Does it work?"), "Three" = p("I hope so.") ) )
Learn more at https://getbootstrap.com/docs/5.1/components/alerts/.
bs_alert(x, div_attr = c(class = "alert alert-primary"))
bs_alert(x, div_attr = c(class = "alert alert-primary"))
x |
A string, the HTML or text to display in the alert. |
div_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the div containing the alert. |
A string of HTML.
bs_alert( "Hello" )
bs_alert( "Hello" )
Learn more at https://getbootstrap.com/docs/5.1/components/badge/.
bs_badge(x, span_attr = c(class = "badge bg-secondary"))
bs_badge(x, span_attr = c(class = "badge bg-secondary"))
x |
A string, the text to display in the badge (uses the <span> tag). |
span_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the span containing the badge text. |
A string of HTML.
bs_badge( "Hello" )
bs_badge( "Hello" )
Create a Bootstrap breadcrumb
bs_breadcrumb( items = list(), active = NULL, nav_attr = c(`aria-label` = "breadcrumb"), ul_attr = c(class = "breadcrumb"), li_attr = c(class = "breadcrumb-item"), a_attr = NULL )
bs_breadcrumb( items = list(), active = NULL, nav_attr = c(`aria-label` = "breadcrumb"), ul_attr = c(class = "breadcrumb"), li_attr = c(class = "breadcrumb-item"), a_attr = NULL )
items |
A list, creates nav elements. If a list item is named, names should be links and values should be text to display in the nav for that link. Names will be passed to the href attribute and values to the main content of the html5::a function which will be wrapped by the html5::li function, each of which have Bootstrap classes added by default. If an item in the list is not named, the item must be valid HTML with appropriate Bootstrap classes added manually. For example, to add a drop-down, add an unnamed item to the list with HTML defining the drop-down as the value of the item. |
active |
A integer, the position in items to make active. |
nav_attr |
A named list or named vector, names are attribute names and values are attribute values. Passed to the attr parameter of html5::nav. |
ul_attr |
A named list or named vector, names are attribute names and values are attribute values. Passed to the attr parameter of html5::ul. |
li_attr |
A named list or named vector, names are attribute names and values are attribute values. Passed to the attr parameter of html5::li. |
a_attr |
A named list or named vector, names are attribute names and values are attribute values. Passed to the attr parameter of html5::a. |
A string of HTML.
bs_breadcrumb( items = list( "#" = "Option 1", "#" = "Option 2", "#" = "Option 3" ), active = 2 )
bs_breadcrumb( items = list( "#" = "Option 1", "#" = "Option 2", "#" = "Option 3" ), active = 2 )
Learn more at https://getbootstrap.com/docs/5.1/components/card/.
bs_card( header = NULL, title = NULL, text = NULL, body, footer = NULL, img_src = NULL, img_alt = NULL, div_attr = c(class = "card"), header_attr = c(class = "card-header"), title_attr = c(class = "card-title"), text_attr = c(class = "card-text"), body_attr = c(class = "card-body"), footer_attr = c(class = "card-footer"), img_attr = c(class = "card-img-top"), header_func = h5, title_func = h5, text_func = h5, img_left = FALSE, img_right = FALSE, img_col_attr = c(class = "col-md-6"), body_col_attr = c(class = "col-md-6"), img_horizontal_attr = c(class = "img-fluid") )
bs_card( header = NULL, title = NULL, text = NULL, body, footer = NULL, img_src = NULL, img_alt = NULL, div_attr = c(class = "card"), header_attr = c(class = "card-header"), title_attr = c(class = "card-title"), text_attr = c(class = "card-text"), body_attr = c(class = "card-body"), footer_attr = c(class = "card-footer"), img_attr = c(class = "card-img-top"), header_func = h5, title_func = h5, text_func = h5, img_left = FALSE, img_right = FALSE, img_col_attr = c(class = "col-md-6"), body_col_attr = c(class = "col-md-6"), img_horizontal_attr = c(class = "img-fluid") )
header |
A string, the HTML to display in the header of the card. |
title |
A string, the HTML to display in the title of the card. |
text |
A string, the HTML to display in the text of the card. |
body |
A string, the HTML to display in the body of the card. |
footer |
A string, the HTML to display in the footer of the card. |
img_src |
A string, the path of an image to display with the card. Passed to "src" attribute of the <img> tag. |
img_alt |
A string, the alt attribute of an image to display with the card. Passed to "alt" attribute of the <img> tag. |
div_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the div wrapping the card content. |
header_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the card header. |
title_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the card title. |
text_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the card text. |
body_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the div wrapping the card body. |
footer_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the div wrapping the card footer. |
img_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the img tag if an image is to be displayed. |
header_func |
A html5 function to use for the header input. |
title_func |
A html5 function to use for the title input. |
text_func |
A html5 function to use for the text input. |
img_left |
TRUE/FALSE, if TRUE, places the image on the left of the card |
img_right |
TRUE/FALSE, if TRUE, places the image on the right of the card |
img_col_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the column containing the img tag if an image is to be displayed horizontally. |
body_col_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the column containing the body if an image is to be displayed horizontally. |
img_horizontal_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the img tag if an image is to be displayed horizontally. |
A string of HTML.
bs_card( body = "This is a card" )
bs_card( body = "This is a card" )
Learn more at https://getbootstrap.com/docs/5.1/components/carousel/.
bs_carousel( id, items = list(), carousel_attr = c(class = "carousel slide"), inner_attr = c(class = "carousel-inner"), item_attr = c(class = "carousel-item"), controls = TRUE )
bs_carousel( id, items = list(), carousel_attr = c(class = "carousel slide"), inner_attr = c(class = "carousel-inner"), item_attr = c(class = "carousel-item"), controls = TRUE )
id |
A string, the id to use for the carousel div. |
items |
A list, entries should be HTML to display in the carousel. |
carousel_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the div wrapping the carousel content. |
inner_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the div wrapping the carousel items. |
item_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the div wrapping each carousel item. |
controls |
TRUE/FALSE, if TRUE, adds code to display arrows to click through the carousel. |
A string of HTML.
bs_carousel( id = "c1", items = list( h1("First slide"), h1("Second slide"), h1("Third Slide") ) )
bs_carousel( id = "c1", items = list( h1("First slide"), h1("Second slide"), h1("Third Slide") ) )
Learn more at https://getbootstrap.com/docs/5.1/layout/columns/.
bs_clearfix(..., clearfix_attr = c(class = "clearfix"))
bs_clearfix(..., clearfix_attr = c(class = "clearfix"))
... |
Valid string(s) of HTML. |
clearfix_attr |
A named list or named vector, names are attribute names and values are attribute values. |
A string of HTML.
bs_clearfix( p("Test") )
bs_clearfix( p("Test") )
Learn more at https://getbootstrap.com/docs/5.1/layout/columns/.
bs_col(..., col_attr = c(class = "col"))
bs_col(..., col_attr = c(class = "col"))
... |
A string or strings of HTML content to include in the col div. |
col_attr |
A named list or named vector, names are attribute names and values are attribute values. |
A string of HTML.
bs_col(p("Col 1"))
bs_col(p("Col 1"))
Learn more at https://getbootstrap.com/docs/5.1/layout/columns/.
bs_col_break(col_break_attr = c(class = "w-100"))
bs_col_break(col_break_attr = c(class = "w-100"))
col_break_attr |
A named list or named vector, names are attribute names and values are attribute values. |
A string of HTML.
bs_col_break()
bs_col_break()
Learn more at https://getbootstrap.com/docs/5.1/components/collapse/.
bs_collapse( id, button_label, content, button_attr = c(class = "btn btn-primary"), content_attr = c(class = "collapse") )
bs_collapse( id, button_label, content, button_attr = c(class = "btn btn-primary"), content_attr = c(class = "collapse") )
id |
A string, the id to use for the collapse div. |
button_label |
A string, the text to display in the button controlling the collapsible content. |
content |
A string, the HTML to display or collapse. |
button_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the button controlling the collapse. |
content_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the div wrapping the collapsible content. |
A string of HTML.
bs_collapse( id = "collapse1", button_label = "Click to Expand", content = p("Hello") )
bs_collapse( id = "collapse1", button_label = "Click to Expand", content = p("Hello") )
Create a Bootstrap container div.
bs_container(..., container_attr = c(class = "container"))
bs_container(..., container_attr = c(class = "container"))
... |
A string or strings of HTML content to include in the container div. |
container_attr |
A named list or named vector, names are attribute names and values are attribute values. |
Learn more at https://getbootstrap.com/docs/5.1/layout/containers/.
A string of HTML.
bs_container( div() )
bs_container( div() )
Learn more at https://getbootstrap.com/docs/5.1/getting-started/introduction/.
bs_doc( head = NULL, body, body_attr = NULL, css_href = css_href_var, css_integrity = css_integrity_var, js_src = js_src_var, js_integrity = js_integrity_var )
bs_doc( head = NULL, body, body_attr = NULL, css_href = css_href_var, css_integrity = css_integrity_var, js_src = js_src_var, js_integrity = js_integrity_var )
head |
A string of HTML that will be passed to the ... param of the html5::head() function. |
body |
A string of HTML that will be passed to the ... param of the html5::body() function. |
body_attr |
A named list or named vector, passed to the attr param of the html5::body() function. |
css_href |
The url of jsDelivr for the version of bootstrap css to include. |
css_integrity |
The integrity string for the version of bootstrap css to include. |
js_src |
The url of jsDelivr for the version of bootstrap js bundle to include. |
js_integrity |
The integrity string for the version of bootstrap js bundle to include. |
A string of HTML.
bs_doc( body = div(h1("Hello"), p("Welcome to this page.")) )
bs_doc( body = div(h1("Hello"), p("Welcome to this page.")) )
Learn more at https://getbootstrap.com/docs/5.1/components/dropdowns/.
bs_dropdown( id, items = list(), button_label = "Dropdown Button", dropdown_attr = c(class = "dropdown"), button_attr = c(class = "btn btn-secondary dropdown-toggle"), ul_attr = c(class = "dropdown-menu"), li_attr = NULL, a_attr = c(class = "dropdown-item") )
bs_dropdown( id, items = list(), button_label = "Dropdown Button", dropdown_attr = c(class = "dropdown"), button_attr = c(class = "btn btn-secondary dropdown-toggle"), ul_attr = c(class = "dropdown-menu"), li_attr = NULL, a_attr = c(class = "dropdown-item") )
id |
A string, the id to use for the dropdown, must be unique within a page (if you have multiple dropdowns on a page). |
items |
A named list, names become the href for each item, values should be the text to display for each href. If an item is unnamed, the value does not get passed to the li/a tags and is instead displayed as-is (useful for displaying custom HTML content in the dropdown). |
button_label |
A string, the label to use for the dropdown toggle button. |
dropdown_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the div wrapping the dropdown elements. |
button_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the button controlling the dropdown toggle. |
ul_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the "ul" tag wrapping the dropdown nav elements. |
li_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the "li" tags wrapping the dropdown nav elements if the input list item is named. |
a_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the "a" tags wrapping the dropdown nav elements if the input list item is named. |
A string of HTML.
bs_dropdown( id = "drop", items = list( "#" = "Home", "#" = "About", "#" = "Other" ) )
bs_dropdown( id = "drop", items = list( "#" = "Home", "#" = "About", "#" = "Other" ) )
Learn more at https://getbootstrap.com/docs/5.1/content/figures/.
bs_figure( figure_attr = c(class = "figure"), img_attr = c(src = "...", alt = "...", class = "figure-img img-fluid"), figcaption_attr = c(class = "figure-caption"), figcaption = NULL )
bs_figure( figure_attr = c(class = "figure"), img_attr = c(src = "...", alt = "...", class = "figure-img img-fluid"), figcaption_attr = c(class = "figure-caption"), figcaption = NULL )
figure_attr |
A named list or named vector, names are attribute names and values are attribute values. Passed to the attr parameter of html5::figure. |
img_attr |
A named list or named vector, names are attribute names and values are attribute values. Passed to the attr parameter of html5::img. |
figcaption_attr |
A named list or named vector, names are attribute names and values are attribute values. Passed to the attr parameter of html5::figcaption. |
figcaption |
A string, gets passed to html5::figcaption. |
A string of HTML.
bs_figure( img_attr = c( "src" = "...", "alt" = "...", "class" = "figure-img img-fluid" ) )
bs_figure( img_attr = c( "src" = "...", "alt" = "...", "class" = "figure-img img-fluid" ) )
Learn more at https://getbootstrap.com/docs/5.1/utilities/flex/.
bs_flexbox(x, div_attr = c(class = "d-flex justify-content-center"))
bs_flexbox(x, div_attr = c(class = "d-flex justify-content-center"))
x |
A string, the HTML or text to display in the div. |
div_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the div containing x. Defaults to center the content of x. |
A string of HTML.
bs_flexbox( p("Hello") )
bs_flexbox( p("Hello") )
Learn more at https://getbootstrap.com/docs/5.1/content/images/.
bs_img(img_attr = c(src = "...", alt = "...", class = "img"), center = FALSE)
bs_img(img_attr = c(src = "...", alt = "...", class = "img"), center = FALSE)
img_attr |
A named list or named vector, names are attribute names and values are attribute values. Passed to the attr parameter of html5::img. |
center |
TRUE/FALSE, if TRUE, wraps img tag in a div with class "text-center". |
A string of HTML.
bs_img( img_attr = c( "src" = "...", "alt" = "...", "class" = "img" ) )
bs_img( img_attr = c( "src" = "...", "alt" = "...", "class" = "img" ) )
Learn more at https://getbootstrap.com/docs/5.1/forms/overview/.
bs_input( id, type = "text", value = NULL, placeholder = NULL, label = NULL, text = NULL, required = FALSE, div_attr = NULL, input_attr = c(class = "form-control"), label_attr = c(class = "form-label"), text_attr = c(class = "form-text"), inline = FALSE )
bs_input( id, type = "text", value = NULL, placeholder = NULL, label = NULL, text = NULL, required = FALSE, div_attr = NULL, input_attr = c(class = "form-control"), label_attr = c(class = "form-label"), text_attr = c(class = "form-text"), inline = FALSE )
id |
A string, the id/name for the input, passed to the id and name attributes of the <input> tag. |
type |
A string, the type of input to create, passed to the type attribute of the <input> tag. |
value |
A string, the value of the input, passed to the value attribute of the <input> tag. |
placeholder |
A string, passed to the placeholder attribute of the <input> tag. |
label |
A string, passed to the <label> tag. |
text |
A string, text or HTML to display with the input and label tags. |
required |
TRUE/FALSE, if TRUE, will add the required attribute to the input tag. |
div_attr |
A named list or named vector, names are attribute names and values are attribute values. Passed to the attr parameter of html5::div, wrapping the input, label, and text. |
input_attr |
A named list or named vector, names are attribute names and values are attribute values. Passed to the attr parameter of html5::input, but id (also name), type, value, and placeholder have their own parameters. |
label_attr |
A named list or named vector, names are attribute names and values are attribute values. Passed to the attr parameter of html5::label. |
text_attr |
A named list or named vector, names are attribute names and values are attribute values. Passed to the attr parameter of html5::div, which will display the text parameter. |
inline |
TRUE/FALSE, if TRUE, adds a div and classes to display the label, input, and text in the same line. |
A string of HTML.
bs_input( id = "example1", label = "Example Text Input" )
bs_input( id = "example1", label = "Example Text Input" )
Learn more at https://getbootstrap.com/docs/5.1/components/modal/.
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") )
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") )
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. |
A string of HTML.
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.") ) )
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.") ) )
Create a Bootstrap offcanvas
bs_offcanvas( id = "offcanvas", header, title = NULL, body, offcanvas_attr = c(class = "offcanvas offcanvas-start", tabindex = "-1", `aria-labelledby` = "offcanvasLabel"), header_attr = c(class = "offcanvas-header"), title_attr = c(class = "offcanvas-title", id = "offcanvasLabel"), body_attr = c(class = "offcanvas-body"), title_function = h5 )
bs_offcanvas( id = "offcanvas", header, title = NULL, body, offcanvas_attr = c(class = "offcanvas offcanvas-start", tabindex = "-1", `aria-labelledby` = "offcanvasLabel"), header_attr = c(class = "offcanvas-header"), title_attr = c(class = "offcanvas-title", id = "offcanvasLabel"), body_attr = c(class = "offcanvas-body"), title_function = h5 )
id |
A string, the id for the div of the offcanvas. |
header |
A string, the HTML to display in the header of the offcanvas. |
title |
A string, the HTML to display in the title of the offcanvas. |
body |
A string, the HTML to display in the body of the offcanvas. |
offcanvas_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the div wrapping the offcanvas content. |
header_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the div wrapping the offcanvas header. |
title_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the tag containing the offcanvas title. |
body_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the div wrapping the offcanvas body. |
title_function |
A function, most likely from the html5 package, containing the attr parameter to be used to generate the title, defaults to h5. |
A string of HTML.
bs_offcanvas( header = "Hello", body = p("This is a offcanvas.") )
bs_offcanvas( header = "Hello", body = p("This is a offcanvas.") )
Learn more at https://getbootstrap.com/docs/5.1/components/pagination/.
bs_pagination( items = list(), ul_attr = c(class = "pagination"), li_attr = c(class = "page-item"), a_attr = c(class = "page-link") )
bs_pagination( items = list(), ul_attr = c(class = "pagination"), li_attr = c(class = "page-item"), a_attr = c(class = "page-link") )
items |
A list, creates nav elements. If a list item is named, names should be links and values should be text to display in the pagination bar for that link. Names will be passed to the href attribute and values to the main content of the html5::a function which will be wrapped by the html5::li function, each of which have Bootstrap classes added by default. If an item in the list is not named, the item must be valid HTML with appropriate Bootstrap classes added manually. |
ul_attr |
A named list or named vector, names are attribute names and values are attribute values. Used for the "ul" tag wrapping the nav elements. |
li_attr |
A named list or named vector, names are attribute names and values are attribute values. Used for the "li" tags wrapping the nav elements if the input list item is named. |
a_attr |
A named list or named vector, names are attribute names and values are attribute values. Used for the "a" tags wrapping the nav elements if the input list item is named. |
A string of HTML.
bs_pagination( items = list( "#" = "Previous", "#" = "1", "#" = "2", "#" = "3", "#" = "Next" ) )
bs_pagination( items = list( "#" = "Previous", "#" = "1", "#" = "2", "#" = "3", "#" = "Next" ) )
"#0d6efd"
bs_primary
bs_primary
A string
Learn more at https://getbootstrap.com/docs/5.1/layout/grid/.
bs_row(..., row_attr = c(class = "row"))
bs_row(..., row_attr = c(class = "row"))
... |
A string or strings of HTML content to include in the row div. |
row_attr |
A named list or named vector, names are attribute names and values are attribute values. |
A string of HTML.
bs_row( bs_col(p("Col 1")), bs_col(p("Col 2")) )
bs_row( bs_col(p("Col 1")), bs_col(p("Col 2")) )
"#6c757d"
bs_secondary
bs_secondary
A string
Learn more at https://getbootstrap.com/docs/5.1/forms/overview/.
bs_select( ..., id, label = NULL, text = NULL, multiple = FALSE, required = FALSE, div_attr = NULL, select_attr = c(class = "form-select"), label_attr = c(class = "form-label"), text_attr = c(class = "form-text") )
bs_select( ..., id, label = NULL, text = NULL, multiple = FALSE, required = FALSE, div_attr = NULL, select_attr = c(class = "form-select"), label_attr = c(class = "form-label"), text_attr = c(class = "form-text") )
... |
A string or strings of HTML to pass to html5::select(), most likely a sequence of option tags. |
id |
A string, the id/name for the select, passed to the id and name attributes of the <select> tag. |
label |
A string, the label to use for the select, passed to html5::label(). |
text |
A string, text or HTML to display with the select and label tags. |
multiple |
TRUE/FALSE, if TRUE, adds the "multiple" attribute to the select tag. |
required |
TRUE/FALSE, if TRUE, will add the required attribute to the select tag. |
div_attr |
A named list or named vector, names are attribute names and values are attribute values. Passed to the attr parameter of html5::div, wrapping the select, label, and text. |
select_attr |
A named list or named vector, names are attribute names and values are attribute values. Passed to the attr parameter of html5::select. |
label_attr |
A named list or named vector, names are attribute names and values are attribute values. Passed to the attr parameter of html5::label. |
text_attr |
A named list or named vector, names are attribute names and values are attribute values. Passed to the attr parameter of html5::div, which will display the text parameter. |
A string of HTML.
bs_select( option(attr = c(value = 1), "Option One"), option(attr = c(value = 2), "Option Two"), id = "example1", label = "Example Select Input" )
bs_select( option(attr = c(value = 1), "Option One"), option(attr = c(value = 2), "Option Two"), id = "example1", label = "Example Select Input" )
Learn more at https://getbootstrap.com/docs/5.1/components/spinners/.
bs_spinner(div_attr = c(class = "spinner-border text-primary"))
bs_spinner(div_attr = c(class = "spinner-border text-primary"))
div_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the div displaying the spinner. |
A string of HTML.
bs_spinner()
bs_spinner()
"#198754"
bs_success
bs_success
A string
Learn more at https://getbootstrap.com/docs/5.1/content/tables/.
bs_table( x, id, headers = NULL, table_attr = list(class = "table"), thead_attr = NULL, tbody_attr = NULL, tr_attr = NULL, th_attr = list(scope = "col"), td_attr = NULL, wrapper_attr = NULL )
bs_table( x, id, headers = NULL, table_attr = list(class = "table"), thead_attr = NULL, tbody_attr = NULL, tr_attr = NULL, th_attr = list(scope = "col"), td_attr = NULL, wrapper_attr = NULL )
x |
A data frame or list with entries of equal length. |
id |
A string, the id for the table. |
headers |
A vector of names to use as table headers instead of the list names (or 1, 2, 3, etc. if list is not named). |
table_attr |
A named list or named vector, names are attribute names and values are attribute values. Passed to the attr parameter of html5::table. |
thead_attr |
A named list or named vector, names are attribute names and values are attribute values. Passed to the attr parameter of html5::thead. |
tbody_attr |
A named list or named vector, names are attribute names and values are attribute values. Passed to the attr parameter of html5::tbody. |
tr_attr |
A named list or named vector, names are attribute names and values are attribute values. Passed to the attr parameter of html5::tr. |
th_attr |
A named list or named vector, names are attribute names and values are attribute values. Passed to the attr parameter of html5::th. |
td_attr |
A named list or named vector, names are attribute names and values are attribute values. Passed to the attr parameter of html5::td. |
wrapper_attr |
A named list or named vector, names are attribute names and values are attribute values. Passed to the attr parameter of html5::div wrapping html5::table. |
A string of HTML.
bs_table( id = "t1", x = list( col1 = c(1, 2, 3, 4, 5), col2 = c("a", "b", "c", "d", "e"), col3 = c(1, 2, 3, 4, 5), col4 = c("test", "test", "test", "test", "test") ) )
bs_table( id = "t1", x = list( col1 = c(1, 2, 3, 4, 5), col2 = c("a", "b", "c", "d", "e"), col3 = c(1, 2, 3, 4, 5), col4 = c("test", "test", "test", "test", "test") ) )
Learn more at https://getbootstrap.com/docs/5.1/forms/overview/.
bs_textarea( id, value = NULL, label = NULL, placeholder = NULL, text = NULL, inline = FALSE, required = FALSE, div_attr = NULL, textarea_attr = c(class = "form-control"), label_attr = c(class = "form-label"), text_attr = c(class = "form-text") )
bs_textarea( id, value = NULL, label = NULL, placeholder = NULL, text = NULL, inline = FALSE, required = FALSE, div_attr = NULL, textarea_attr = c(class = "form-control"), label_attr = c(class = "form-label"), text_attr = c(class = "form-text") )
id |
A string, the id/name for the textarea, passed to the id and name attributes of the <textarea> tag. |
value |
A string, the value of the textarea, passed to the value attribute of the <textarea> tag. |
label |
A string, the label to use for the textarea, passed to html5::label. |
placeholder |
A string, passed to the placeholder attribute of the <textarea> tag. |
text |
A string, text or HTML to display with the textarea and label tags. |
inline |
TRUE/FALSE, if TRUE, adds a div and classes to display the label and textarea and text in the same line. |
required |
TRUE/FALSE, if TRUE, will add the required attribute to the textarea tag. |
div_attr |
A named list or named vector, names are attribute names and values are attribute values. Passed to the attr parameter of html5::div, wrapping the textarea, label, and text. |
textarea_attr |
A named list or named vector, names are attribute names and values are attribute values. Passed to the attr parameter of html5::textarea. |
label_attr |
A named list or named vector, names are attribute names and values are attribute values. Passed to the attr parameter of html5::label. |
text_attr |
A named list or named vector, names are attribute names and values are attribute values. Passed to the attr parameter of html5::div, which will display the text parameter. |
A string of HTML.
bs_textarea( id = "example1", label = "Example Text Area Input" )
bs_textarea( id = "example1", label = "Example Text Area Input" )
Create a Bootstrap toast
bs_toast( id, header, body, default_close_button = TRUE, on_load = TRUE, toast_attr = c(class = "toast", role = "alert", `aria-live` = "assertive", `aria-atomic` = "true", `data-bs-autohide` = "false"), header_attr = c(class = "toast-header"), body_attr = c(class = "toast-body") )
bs_toast( id, header, body, default_close_button = TRUE, on_load = TRUE, toast_attr = c(class = "toast", role = "alert", `aria-live` = "assertive", `aria-atomic` = "true", `data-bs-autohide` = "false"), header_attr = c(class = "toast-header"), body_attr = c(class = "toast-body") )
id |
A string, the id for the div of the toast. |
header |
A string, the HTML to display in the header of the toast. |
body |
A string, the HTML to display in the body of the toast. |
default_close_button |
TRUE/FALSE, if TRUE, adds code to display the default toast close button, otherwise the close button should be added manually. |
on_load |
TRUE/FALSE, if TRUE, adds a script tag with javascript to show the toast by id on load. |
toast_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the div wrapping the toast content. |
header_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the div wrapping the toast header. |
body_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the div wrapping the toast body. |
A string of HTML.
bs_toast( id = "toast1", header = "Hello", body = "This is a toast" )
bs_toast( id = "toast1", header = "Hello", body = "This is a toast" )
Create a Bootstrap toast container
bs_toast_container(..., div_attr = c(class = "toast-container"))
bs_toast_container(..., div_attr = c(class = "toast-container"))
... |
A string, the HTML to display in the toast container. |
div_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the div wrapping .... |
A string of HTML.
bs_toast_container( bs_toast( id = "toast1", header = "Hello", body = "This is a toast" ) )
bs_toast_container( bs_toast( id = "toast1", header = "Hello", body = "This is a toast" ) )
Create a <script> tag to initialize the Bootstrap javascript for creating toasts. Must include in HTML document if using a toast.
bs_toast_js()
bs_toast_js()
A string of HTML.
bs_toast_js()
bs_toast_js()
#ffc107"
bs_warning
bs_warning
A string
"https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
css_href_var
css_href_var
A string
"sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC"
css_integrity_var
css_integrity_var
A string
"sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM"
js_integrity_var
js_integrity_var
A string
"https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
js_src_var
js_src_var
A string