Easily Insert SVG Icons into R Outputs

Provides tools to download, style, and insert scalable vector graphics (SVG) icons into R output, such as 'R Markdown' and 'Quarto' documents, 'Shiny' apps, 'gt' tables, and 'ggplot2' visualisations via the 'ggicons' package. Bundles popular icon libraries, such as 'Font Awesome' (< https://fontawesome.com>), 'Academicons' (< https://jpswalsh.github.io/academicons/>), and 'Material Design Icons' (< https://fonts.google.com/icons>), which are downloaded on demand to keep the package small, or build a custom icon set from any folder of local SVG files. Icon appearance, such as size, colour, and position, can be customised.


icons

R-CMD-check lifecycle CRAN_Status_Badge

The icons package for R makes adding web icons to reports, presentations and apps easy. It integrates many popular icon libraries from around the web with a simple interface that works with any rmarkdown output format. If a particular icon library is not explicitly supported by this package, you can still use it by creating a custom icon set from a folder of SVG files. Icons provide flexible means of digital expression, allowing expressions and functionality beyond what is possible with emoji.

The icons package currently provides helpful tools for downloading and using icons from these libraries:

Installation

The released version can be installed from CRAN using:

install.packages("icons")

The development version can be installed from GitHub using:

# install.packages("remotes")
remotes::install_github("mitchelloharawild/icons")

Once you’ve installed the package you’ll also need to download some icons! Supported icon libraries (listed above) can be downloaded using the download_*() functions. For example, to download the Font Awesome icons you would use download_fontawesome().

Usage

library(icons)

Icons can be inserted inline using inline code `r icons::fontawesome("rocket", style = "solid")` or `r icons::fontawesome$solid$rocket` .

Icons can also be inserted using usual R chunks.

```{r icon-chunk}
fontawesome("rocket", style = "solid") # equivalent to icons::fontawesome$solid$rocket
```

If the icon name contains non-syntactic name characters like a - or +, you will need to quote the name with backticks, single or double quotes:

fontawesome$brands$`r-project` # or 'r-project' or "r-project"

The appearance of an icon can be customised using the icon_style() function.

```{r icon-style}
icon_style(fontawesome("rocket", style = "solid"), scale = 2, fill = "red")
```

Custom icon sets can be created using the icon_set() function, which accepts a directory of SVG files and allows them to be used as icons.

```{r icon-custom}
custom <- icons::icon_set("hex")
custom$icons
```

You can also search for icons using the icon_find() function, which returns a vector of matching icons. Use icon_label() to see which icon set and name each match came from.

found <- icon_find("rocket")
found

icon_label(found)
#> [1] "ionicons$rocket"          "fontawesome$solid$rocket"

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("icons")

1.0.0 by Mitchell O'Hara-Wild, 2 months ago


https://pkg.mitchelloharawild.com/icons/, https://github.com/mitchelloharawild/icons


Report a bug at https://github.com/mitchelloharawild/icons/issues


Browse source code at https://github.com/cran/icons


Authors: Mitchell O'Hara-Wild [aut, cre] (ORCID: , Earo Wang [ctb] , Timothy Hyndman [ctb] , Matthew Warkentin [ctb] (ORCID: , Tom Jemmett [ctb]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports base64enc, knitr, rlang, htmltools, glue, rappdirs, xml2, stringr, jsonlite, cli, utils, vctrs

Suggests rsvg, gh, rmarkdown, pillar, shiny, testthat


Imported by ggicons.


See at CRAN