Type: | Package |
Title: | Create HTML Content with Bootstrap 5 Classes and Layouts |
Version: | 1.0.5 |
Author: | Timothy Conwell |
Maintainer: | Timothy Conwell <timconwell@gmail.com> |
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/. |
License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
Encoding: | UTF-8 |
Depends: | R (≥ 3.5.0), html5 (≥ 1.0.0) |
Imports: | toolbox |
RoxygenNote: | 7.2.0 |
NeedsCompilation: | no |
Packaged: | 2022-08-29 18:37:45 UTC; tim |
Repository: | CRAN |
Date/Publication: | 2022-08-29 19:40:02 UTC |
Create a Bootstrap accordion
Description
Learn more at https://getbootstrap.com/docs/5.1/components/accordion/.
Usage
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")
)
Arguments
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. |
Value
A string of HTML.
Examples
bs_accordion(
id = "acc1",
items = list(
"One" = p("Check it out."),
"Two" = p("Does it work?"),
"Three" = p("I hope so.")
)
)
Create a Bootstrap alert
Description
Learn more at https://getbootstrap.com/docs/5.1/components/alerts/.
Usage
bs_alert(x, div_attr = c(class = "alert alert-primary"))
Arguments
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. |
Value
A string of HTML.
Examples
bs_alert(
"Hello"
)
Create a Bootstrap badge
Description
Learn more at https://getbootstrap.com/docs/5.1/components/badge/.
Usage
bs_badge(x, span_attr = c(class = "badge bg-secondary"))
Arguments
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. |
Value
A string of HTML.
Examples
bs_badge(
"Hello"
)
Hex code for bootstrap black color
Description
"#000"
Usage
bs_black
Format
A string
Hex code for bootstrap blue color
Description
"#0d6efd"
Usage
bs_blue
Format
A string
Create a Bootstrap breadcrumb
Description
Create a Bootstrap breadcrumb
Usage
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
)
Arguments
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. |
Value
A string of HTML.
Examples
bs_breadcrumb(
items = list(
"#" = "Option 1",
"#" = "Option 2",
"#" = "Option 3"
),
active = 2
)
Create a Bootstrap card
Description
Learn more at https://getbootstrap.com/docs/5.1/components/card/.
Usage
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")
)
Arguments
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. |
Value
A string of HTML.
Examples
bs_card(
body = "This is a card"
)
Create a Bootstrap carousel
Description
Learn more at https://getbootstrap.com/docs/5.1/components/carousel/.
Usage
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
)
Arguments
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. |
Value
A string of HTML.
Examples
bs_carousel(
id = "c1",
items = list(
h1("First slide"),
h1("Second slide"),
h1("Third Slide")
)
)
Create a div with class "clearfix"
Description
Learn more at https://getbootstrap.com/docs/5.1/layout/columns/.
Usage
bs_clearfix(..., clearfix_attr = c(class = "clearfix"))
Arguments
... |
Valid string(s) of HTML. |
clearfix_attr |
A named list or named vector, names are attribute names and values are attribute values. |
Value
A string of HTML.
Examples
bs_clearfix(
p("Test")
)
Create a Bootstrap col div
Description
Learn more at https://getbootstrap.com/docs/5.1/layout/columns/.
Usage
bs_col(..., col_attr = c(class = "col"))
Arguments
... |
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. |
Value
A string of HTML.
Examples
bs_col(p("Col 1"))
Create a div with class "w-100" to force columns onto a new line
Description
Learn more at https://getbootstrap.com/docs/5.1/layout/columns/.
Usage
bs_col_break(col_break_attr = c(class = "w-100"))
Arguments
col_break_attr |
A named list or named vector, names are attribute names and values are attribute values. |
Value
A string of HTML.
Examples
bs_col_break()
Create a Bootstrap collapse
Description
Learn more at https://getbootstrap.com/docs/5.1/components/collapse/.
Usage
bs_collapse(
id,
button_label,
content,
button_attr = c(class = "btn btn-primary"),
content_attr = c(class = "collapse")
)
Arguments
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. |
Value
A string of HTML.
Examples
bs_collapse(
id = "collapse1",
button_label = "Click to Expand",
content = p("Hello")
)
Create a Bootstrap container div
Description
Create a Bootstrap container div.
Usage
bs_container(..., container_attr = c(class = "container"))
Arguments
... |
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. |
Details
Learn more at https://getbootstrap.com/docs/5.1/layout/containers/.
Value
A string of HTML.
Examples
bs_container(
div()
)
Hex code for bootstrap cyan color
Description
"#0dcaf0"
Usage
bs_cyan
Format
A string
Hex code for bootstrap danger color
Description
"#dc3545"
Usage
bs_danger
Format
A string
Hex code for bootstrap dark color
Description
"#212529"
Usage
bs_dark
Format
A string
Create a HTML document preconfigured to load Bootstrap5 from the CDN
Description
Learn more at https://getbootstrap.com/docs/5.1/getting-started/introduction/.
Usage
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
)
Arguments
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. |
Value
A string of HTML.
Examples
bs_doc(
body = div(h1("Hello"), p("Welcome to this page."))
)
Create a Bootstrap dropdown
Description
Learn more at https://getbootstrap.com/docs/5.1/components/dropdowns/.
Usage
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")
)
Arguments
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. |
Value
A string of HTML.
Examples
bs_dropdown(
id = "drop",
items = list(
"#" = "Home",
"#" = "About",
"#" = "Other"
)
)
Create HTML figure tag configured with Bootstrap classes
Description
Learn more at https://getbootstrap.com/docs/5.1/content/figures/.
Usage
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
)
Arguments
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. |
Value
A string of HTML.
Examples
bs_figure(
img_attr = c(
"src" = "...",
"alt" = "...",
"class" = "figure-img img-fluid"
)
)
Create a Bootstrap flexbox
Description
Learn more at https://getbootstrap.com/docs/5.1/utilities/flex/.
Usage
bs_flexbox(x, div_attr = c(class = "d-flex justify-content-center"))
Arguments
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. |
Value
A string of HTML.
Examples
bs_flexbox(
p("Hello")
)
Hex code for bootstrap green color
Description
"#198754"
Usage
bs_green
Format
A string
Create HTML img tag configured with Bootstrap classes
Description
Learn more at https://getbootstrap.com/docs/5.1/content/images/.
Usage
bs_img(img_attr = c(src = "...", alt = "...", class = "img"), center = FALSE)
Arguments
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". |
Value
A string of HTML.
Examples
bs_img(
img_attr = c(
"src" = "...",
"alt" = "...",
"class" = "img"
)
)
Hex code for bootstrap indigo color
Description
"#6610f2"
Usage
bs_indigo
Format
A string
Hex code for bootstrap info color
Description
"#0dcaf0"
Usage
bs_info
Format
A string
Create a HTML input tag configured with Bootstrap classes
Description
Learn more at https://getbootstrap.com/docs/5.1/forms/overview/.
Usage
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
)
Arguments
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. |
Value
A string of HTML.
Examples
bs_input(
id = "example1",
label = "Example Text Input"
)
Hex code for bootstrap light color
Description
"#f8f9fa"
Usage
bs_light
Format
A string
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.")
)
)
Create a Bootstrap nav
Description
Learn more at https://getbootstrap.com/docs/5.1/components/navs-tabs/.
Usage
bs_nav(
items = list(),
vertical = FALSE,
nav_attr = c(class = "nav"),
ul_attr = c(class = "nav"),
li_attr = c(class = "nav-item"),
a_attr = c(class = "nav-link")
)
Arguments
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. |
vertical |
TRUE/FALSE, if TRUE, makes the nav vertical. |
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. |
Value
A string of HTML.
Examples
bs_nav(
items = list(
"#" = "Option 1",
"#" = "Option 2",
"#" = "Option 3"
)
)
Create a Bootstrap navbar
Description
Learn more at https://getbootstrap.com/docs/5.1/components/navbar/.
Usage
bs_navbar(
id = toolbox::sampleStr(12, sample_chars = c(letters, LETTERS)),
brand = list(),
from_left = list(),
from_right = list(),
nav_attr = c(class = "navbar bg-primary navbar-dark navbar-expand-lg"),
container_attr = c(class = "container-fluid"),
div_attr = c(),
brand_attr = c(class = "navbar-brand"),
from_left_ul_attr = c(class = "navbar-nav me-auto"),
from_right_ul_attr = c(class = "navbar-nav"),
li_attr = c(class = "nav-item"),
a_attr = c(class = "nav-link")
)
Arguments
id |
A string, used to control the collapse/expand functionality. Defaults to a random string. |
brand |
A named list of length 1, name should be a value suitable for the href attribute of html5::a and the value is the HTML or text to display in the a tag. |
from_left |
A list, creates navbar elements arranged to the left. If a list item is named, names should be links and values should be text to display in the navbar 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. |
from_right |
A list, creates navbar elements arranged to the right. If a list item is named, names should be links and values should be text to display in the navbar 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. |
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. |
container_attr |
A named list or named vector, names are attribute names and values are attribute values. Passed to the attr parameter of html5::div to be used as a container. |
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 brand and left and right content. |
brand_attr |
A named list or named vector, names are attribute names and values are attribute values. Passed to the attr parameter of html5::a containing the brand href and text. |
from_left_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. |
from_right_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. |
Value
A string of HTML.
Examples
bs_navbar(
brand = list("#" = "Sample Brand"),
from_left = list(
"/" = "Home",
"/about" = "About"
),
from_right = list(
"/options" = "Options"
)
)
Create a Bootstrap offcanvas
Description
Create a Bootstrap offcanvas
Usage
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
)
Arguments
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. |
Value
A string of HTML.
Examples
bs_offcanvas(
header = "Hello",
body = p("This is a offcanvas.")
)
Hex code for bootstrap orange color
Description
"#fd7e14"
Usage
bs_orange
Format
A string
Create a Bootstrap pagination nav
Description
Learn more at https://getbootstrap.com/docs/5.1/components/pagination/.
Usage
bs_pagination(
items = list(),
ul_attr = c(class = "pagination"),
li_attr = c(class = "page-item"),
a_attr = c(class = "page-link")
)
Arguments
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. |
Value
A string of HTML.
Examples
bs_pagination(
items = list(
"#" = "Previous",
"#" = "1",
"#" = "2",
"#" = "3",
"#" = "Next"
)
)
Hex code for bootstrap pink color
Description
"#d63384"
Usage
bs_pink
Format
A string
Hex code for bootstrap primary color
Description
"#0d6efd"
Usage
bs_primary
Format
A string
Hex code for bootstrap purple color
Description
"#6f42c1"
Usage
bs_purple
Format
A string
Hex code for bootstrap red color
Description
"#dc3545"
Usage
bs_red
Format
A string
Create a Bootstrap row div
Description
Learn more at https://getbootstrap.com/docs/5.1/layout/grid/.
Usage
bs_row(..., row_attr = c(class = "row"))
Arguments
... |
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. |
Value
A string of HTML.
Examples
bs_row(
bs_col(p("Col 1")),
bs_col(p("Col 2"))
)
Hex code for bootstrap secondary color
Description
"#6c757d"
Usage
bs_secondary
Format
A string
Create a HTML select tag configured with Bootstrap classes
Description
Learn more at https://getbootstrap.com/docs/5.1/forms/overview/.
Usage
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")
)
Arguments
... |
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. |
Value
A string of HTML.
Examples
bs_select(
option(attr = c(value = 1), "Option One"),
option(attr = c(value = 2), "Option Two"),
id = "example1",
label = "Example Select Input"
)
Create a Bootstrap spinner
Description
Learn more at https://getbootstrap.com/docs/5.1/components/spinners/.
Usage
bs_spinner(div_attr = c(class = "spinner-border text-primary"))
Arguments
div_attr |
A named list or named vector, names are attribute names and values are attribute values. Added to the div displaying the spinner. |
Value
A string of HTML.
Examples
bs_spinner()
Hex code for bootstrap success color
Description
"#198754"
Usage
bs_success
Format
A string
Create a HTML table configured with Bootstrap classes
Description
Learn more at https://getbootstrap.com/docs/5.1/content/tables/.
Usage
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
)
Arguments
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. |
Value
A string of HTML.
Examples
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")
)
)
Hex code for bootstrap teal color
Description
"#20c997"
Usage
bs_teal
Format
A string
Create a HTML textarea tag configured with Bootstrap classes
Description
Learn more at https://getbootstrap.com/docs/5.1/forms/overview/.
Usage
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")
)
Arguments
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. |
Value
A string of HTML.
Examples
bs_textarea(
id = "example1",
label = "Example Text Area Input"
)
Create a Bootstrap toast
Description
Create a Bootstrap toast
Usage
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")
)
Arguments
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. |
Value
A string of HTML.
Examples
bs_toast(
id = "toast1",
header = "Hello",
body = "This is a toast"
)
Create a Bootstrap toast container
Description
Create a Bootstrap toast container
Usage
bs_toast_container(..., div_attr = c(class = "toast-container"))
Arguments
... |
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 .... |
Value
A string of HTML.
Examples
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.
Description
Create a <script> tag to initialize the Bootstrap javascript for creating toasts. Must include in HTML document if using a toast.
Usage
bs_toast_js()
Value
A string of HTML.
Examples
bs_toast_js()
Hex code for bootstrap warning color
Description
#ffc107"
Usage
bs_warning
Format
A string
Hex code for bootstrap white color
Description
"#fff"
Usage
bs_white
Format
A string
Hex code for bootstrap yellow color
Description
"#ffc107"
Usage
bs_yellow
Format
A string
Variable for the CSS CDN link
Description
"https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css"
Usage
css_href_var
Format
A string
Variable for the CSS CDN integrity string
Description
"sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC"
Usage
css_integrity_var
Format
A string
Variable for the JS CDN integrity string
Description
"sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM"
Usage
js_integrity_var
Format
A string
Variable for the JS CDN link
Description
"https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"
Usage
js_src_var
Format
A string