bs_icon: Use Bootstrap icons (as inline SVG)

View source: R/bs-icon.R

bs_iconR Documentation

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("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 4+ utility classes (e.g., text-success) here to stylize the icon (but also note that those utility classes will only work when Bootstrap 4+ is on the page).

title

An option for populating the SVG 'title' attribute, which provides on-hover text for the icon. By default, no title text is given to the icon. If a11y == "semantic" then title text will be automatically given to the rendered icon, however, providing text here will override that.

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) or "sem" (semantic). Using "none" will result in no accessibility features for the icon.

...

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)
}


bsicons documentation built on Nov. 22, 2022, 5:08 p.m.