Title: Easily Work with 'Bootstrap' Icons
Version: 0.1.2
Description: Easily use 'Bootstrap' icons inside 'Shiny' apps and 'R Markdown' documents. More generally, icons can be inserted in any 'htmltools' document through inline 'SVG'.
License: MIT + file LICENSE
URL: https://github.com/rstudio/bsicons
BugReports: https://github.com/rstudio/bsicons/issues
Depends: R (≥ 2.10)
Imports: cli, htmltools, rlang, utils
Suggests: bslib, processx, testthat, webshot2, withr
Config/testthat/edition: 3
Encoding: UTF-8
RoxygenNote: 7.2.3
NeedsCompilation: no
Packaged: 2023-11-03 23:29:00 UTC; cpsievert
Author: Carson Sievert ORCID iD [cre, aut], Posit Software, PBC [cph, fnd], Mark Otto [cph] (Bootstrap icons maintainer)
Maintainer: Carson Sievert <carson@posit.co>
Repository: CRAN
Date/Publication: 2023-11-04 00:30:05 UTC

bsicons: Easily Work with 'Bootstrap' Icons

Description

Easily use 'Bootstrap' icons inside 'Shiny' apps and 'R Markdown' documents. More generally, icons can be inserted in any 'htmltools' document through inline 'SVG'.

Author(s)

Maintainer: Carson Sievert carson@posit.co (ORCID)

Other contributors:

See Also

Useful links:


Use Bootstrap icons (as inline SVG)

Description

Use Bootstrap icons (as inline SVG)

Usage

bs_icon(
  name,
  size = "1em",
  class = NULL,
  title = NULL,
  a11y = c("auto", "deco", "sem", "none"),
  ...
)

Arguments

name

The name of the Bootstrap icon. Whitespace is replaced with - (that way, "arrow up" can be used to refer to the "actual name" of "arrow-up"). For a searchable list of names, see https://icons.getbootstrap.com/

size

Any valid CSS unit defining both the height and width of the icon.

class

Additional CSS classes to add to the ⁠<svg>⁠ element. Consider providing Bootstrap 5+ utility classes (e.g., text-success) here to stylize the icon (but also note that those utility classes will only work when Bootstrap 5+ is on the page).

title

If provided (highly recommended), a11y defaults to "sem", meaning the title is used for on-hover text and screen reader announcements.

a11y

Cases that distinguish the role of the icon and inform which accessibility attributes to be used. Icons can either be "deco" (decorative, the default case), "sem" (semantic), "none" (no accessibility features). The default, "auto", resolves to "sem" if a title is provided (and "deco" otherwise).

...

additional CSS properties (e.g., margin, position, etc.) placed on the ⁠<svg>⁠ tag.

Value

An htmltools::HTML() string containing the SVG icon.

Examples


up <- bs_icon("arrow-up-circle", size = "9em", class = "text-success")
up_fill <- bs_icon("arrow-up-circle-fill", size = "9em", class = "text-success")

# utility class will only apply with a modern version of Bootstrap
if (interactive() && requireNamespace('bslib')) {
  bslib::page_fluid(up, up_fill)
}