| Title: | Easily Insert SVG Icons into R Outputs |
|---|---|
| Description: | 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. |
| Authors: | Mitchell O'Hara-Wild [aut, cre] (ORCID: <https://orcid.org/0000-0001-6729-7695>), Earo Wang [ctb] (ORCID: <https://orcid.org/0000-0001-6448-5260>), Timothy Hyndman [ctb] (ORCID: <https://orcid.org/0000-0002-7047-5023>), Matthew Warkentin [ctb] (ORCID: <https://orcid.org/0000-0001-8730-3511>), Tom Jemmett [ctb] (ORCID: <https://orcid.org/0000-0002-6943-2990>) |
| Maintainer: | Mitchell O'Hara-Wild <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.0.0 |
| Built: | 2026-10-10 15:06:14 UTC |
| Source: | https://github.com/cran/icons |
Academicons is a specialist icon font for academics. It contains icons for websites and organisations related to academia that are often missing from mainstream font packages. It can be used by itself, but its primary purpose is to be used as a supplementary package alongside a larger icon set.
download_academicons(version = "dev") academicons(name)download_academicons(version = "dev") academicons(name)
version |
Version of the library |
name |
Name of the icon |
download_academicons() invisibly returns the academicons icon
set after downloading and installing its SVG files locally.
academicons(name) returns an icons vector (an SVG tag) for the
requested icon.
Academicons is distributed under the SIL Open Font License 1.1 (see the project README for details).
Bioicons is a free library of open source icons for scientific illustrations using vector graphics software such as Inkscape or Adobe Illustrator.
download_bioicons() bioicons(name, category = NULL)download_bioicons() bioicons(name, category = NULL)
name |
Name of the icon. |
category |
The icon's category, one of "Animals", "Blood_immunology",
"Cell_lines", "Cell_membrane", "Chemistry", "Chemo-_and_Bioinformatics",
"General_items", "Genetics", "Human_physiology", "Intracellular_components"
, "Lab_apparatus", "Machine_Learning", "Microbiology",
"Nucleic_Acids", "Oncology", "Parasites", "Receptor_channels",
"Safety_symbols", "Scientific_graphs", "Tissues", or "Viruses".
If |
download_bioicons() invisibly returns the bioicons icon set
after downloading and installing its SVG files locally.
bioicons(name, category) returns an icons vector (an SVG tag) for
the requested icon.
Each Bioicons icon is contributed under a license chosen by its author -
commonly CC-0, MIT, CC-BY-SA, or BSD. The license is baked into the
icon's identifier (use icon_label() to recover it, e.g.
"bioicons$CC-0$General_items$AuthorName$name"), and is also listed
alongside each icon at https://bioicons.com/. Check, and where
required credit, the individual icon's license before reuse.
Feather Icons
download_feather_icons(version = "dev") feather_icons(name)download_feather_icons(version = "dev") feather_icons(name)
version |
Version of the library |
name |
Name of the icon |
download_feather_icons() invisibly returns the feather_icons
icon set after downloading and installing its SVG files locally.
feather_icons(name) returns an icons vector (an SVG tag) for the
requested icon.
Feather Icons are distributed under the MIT License.
Font Awesome icons
download_fontawesome(version = "dev") fontawesome(name, style = NULL)download_fontawesome(version = "dev") fontawesome(name, style = NULL)
version |
Version of the library |
name |
Name of the icon |
style |
Style of the icon. If NULL, a default style will be chosen for the specified icon. |
download_fontawesome() invisibly returns the fontawesome
icon set after downloading and installing its SVG files locally.
fontawesome(name, style) returns an icons vector (an SVG tag) for
the requested icon.
This package uses Font Awesome Free. Its icons are distributed under the CC BY 4.0 License, which requires attribution when the icons are used.
Google's Material design icons
download_google_material(version = "dev") google_material(name, category = NULL, theme = NULL)download_google_material(version = "dev") google_material(name, category = NULL, theme = NULL)
version |
Version of the library |
name |
Name of the icon |
category |
The icon's category, either "action", "alert", "av", "communication", "content", "device", "editor", "file", "hardware", "home", "image", "maps", "navigation", "notification", "places", "social", or "toggle" |
theme |
The style variant for the icon, requires v4.0.0 or greater. Available themes vary by icon, but can be either "filled", "outlined", "round", "sharp", or "twotone". If NULL, it will default to the first available variant in this order. |
download_google_material() invisibly returns the
google_material icon set after downloading and installing its SVG
files locally.
google_material(name, category, theme) returns an icons vector (an
SVG tag) for the requested icon.
Material Design Icons are distributed under the Apache License 2.0.
https://fonts.google.com/icons
Health icons
download_health_icons() health_icons(name, category = NULL, theme = NULL)download_health_icons() health_icons(name, category = NULL, theme = NULL)
name |
Name of the icon |
category |
The icon's category, either "blood", "body", "conditions", "devices", "diagnostics", "emotions", "family", "medications", "objects", "people", "places", "shapes", "specialties", "symbols", "typography", or "vehicles" |
theme |
The style variant for the icon, requires v4.0.0 or greater. Available themes vary by icon, but can be either "filled", "negative", "outline". If NULL, it will default to the first available variant in this order. |
download_health_icons() invisibly returns the health_icons
icon set after downloading and installing its SVG files locally.
health_icons(name, category, theme) returns an icons vector (an
SVG tag) for the requested icon.
Health Icons are released into the public domain under the CC0 1.0 Universal License; no attribution is required. The Health Icons codebase itself is licensed separately under the MIT License.
Ionicons icons
download_ionicons(version = "dev") ionicons(name)download_ionicons(version = "dev") ionicons(name)
version |
Version of the library |
name |
Name of the icon |
download_ionicons() invisibly returns the ionicons icon set
after downloading and installing its SVG files locally.
ionicons(name) returns an icons vector (an SVG tag) for the
requested icon.
Ionicons are distributed under the MIT License.
GitHub's Octicons
download_octicons(version = "dev") octicons(name)download_octicons(version = "dev") octicons(name)
version |
Version of the library |
name |
Name of the icon |
download_octicons() invisibly returns the octicons icon set
after downloading and installing its SVG files locally.
octicons(name) returns an icons vector (an SVG tag) for the
requested icon.
Octicons are distributed under the MIT License.
https://primer.style/octicons/
Simple Icons
download_simple_icons(version = "dev") simple_icons(name)download_simple_icons(version = "dev") simple_icons(name)
version |
Version of the library |
name |
Name of the icon |
download_simple_icons() invisibly returns the simple_icons
icon set after downloading and installing its SVG files locally.
simple_icons(name) returns an icons vector (an SVG tag) for the
requested icon.
The Simple Icons artwork is distributed under the CC0 1.0 Universal License. Many of the icons depict third-party brands and logos which may be protected as trademarks; read Simple Icons' legal disclaimer before using them.
Super Tiny Icons are miniscule SVG versions of popular website and app logos, each under 1KB in size.
download_super_tiny_icons(version = "dev") super_tiny_icons(name)download_super_tiny_icons(version = "dev") super_tiny_icons(name)
version |
Version of the library |
name |
Name of the icon |
download_super_tiny_icons() invisibly returns the
super_tiny_icons icon set after downloading and installing its SVG
files locally.
super_tiny_icons(name) returns an icons vector (an SVG tag) for the
requested icon.
The project's own icons are dual-licensed by the author under the MIT License and CC0 1.0 Universal License. Many icons are adapted from third-party logos that carry their own licenses (and some depict trademarks), so check the source noted for an icon before reusing it - see the project's licenses list for details.
https://github.com/edent/SuperTinyIcons
Find icons in installed sets by name
icon_find(name, set = NULL)icon_find(name, set = NULL)
name |
The name of the icon |
set |
Icon sets to search. If NULL, all available icons will be searched. |
An icons vector of matching icons (empty if none are found). Use
icon_label() to recover each match's library$sub$name accessor
expression (for example "fontawesome$solid$rocket") - the result
itself carries no names(), since an icons vector can't hold them.
# Empty if no installed icon set has a matching icon icon_find("rocket") if(icon_installed(fontawesome)){ found <- icon_find("rocket") icon_label(found) }# Empty if no installed icon set has a matching icon icon_find("rocket") if(icon_installed(fontawesome)){ found <- icon_find("rocket") icon_label(found) }
This function will return TRUE if the icons for an icon set are installed.
If they aren't, they can be installed using the appropriate download_*()
function.
icon_installed(x)icon_installed(x)
x |
An icon set (such as |
A single TRUE or FALSE.
icon_installed(fontawesome)icon_installed(fontawesome)
Every icon sourced from an installed icon library (as opposed to a local
icon_set() or a raw read_icon() file) has a file path of the form
<cache root>/<library>/<...name parts...>.svg (see 00_registry.R's
icon_fn$get()), which is exactly the library$sub$name expression used
to access it. icon_label() recovers that label straight from
icon_path() rather than requiring a name to be tracked separately —
so, unlike names(), it survives c()/rep()/subsetting on an icons
vector (a vctrs rcrd, which cannot carry element names()).
icon_label(x)icon_label(x)
x |
An |
A character vector the same length as x giving each icon's
library$sub$name label. Icons not sourced from an installed library
(a local icon_set() or a read_icon() file outside the icon cache)
return NA.
path <- tempfile(fileext = ".svg") writeLines( '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M0 0"/></svg>', path ) icon_label(read_icon(path)) # NA - not sourced from an installed library if(icon_installed(fontawesome)){ icon_label(fontawesome("rocket", style = "solid")) }path <- tempfile(fileext = ".svg") writeLines( '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M0 0"/></svg>', path ) icon_label(read_icon(path)) # NA - not sourced from an installed library if(icon_installed(fontawesome)){ icon_label(fontawesome("rocket", style = "solid")) }
Icons created from an SVG file (such as those from an icon_set(), or
read directly with read_icon()) retain the path to their source file.
This is useful for passing icons to other packages that work with SVG
files directly, such as ggplot2 (via grid::rasterGrob() or similar) or
gt.
icon_path(x)icon_path(x)
x |
An |
A character vector giving the path(s) to the icon's source SVG file(s) on disk.
path <- tempfile(fileext = ".svg") writeLines( '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M0 0"/></svg>', path ) icon_path(read_icon(path))path <- tempfile(fileext = ".svg") writeLines( '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M0 0"/></svg>', path ) icon_path(read_icon(path))
Store icons in a local directory to simplify sharing of documents containing icons. Bundling icons with your document or app avoids the need for collaborators or servers to have all icons from a library installed.
icon_save(icons, path = ".")icon_save(icons, path = ".")
icons |
A named list of icons, the names specify the icon's name in the new icon set. |
path |
A directory to save the icons into. |
Invisibly, the icon_set created from the newly saved SVG files
at path.
if(icon_installed(fontawesome) && icon_installed(ionicons)){ path <- tempfile() dir.create(path) icon_save( list(arrow = fontawesome$solid$`arrow-right`, alarm = ionicons$alarm), path = path ) app_icons <- icon_set(path) app_icons$arrow }if(icon_installed(fontawesome) && icon_installed(ionicons)){ path <- tempfile() dir.create(path) icon_save( list(arrow = fontawesome$solid$`arrow-right`, alarm = ionicons$alarm), path = path ) app_icons <- icon_set(path) app_icons$arrow }
Create a custom icon set
icon_set(path, meta = list(name = "Custom", version = NULL, license = NULL))icon_set(path, meta = list(name = "Custom", version = NULL, license = NULL))
path |
Path to the icons |
meta |
Meta information for the icons |
An icon_set object providing access to the SVG files found at
path, for example via $.
dir <- tempfile() dir.create(dir) writeLines( '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M0 0"/></svg>', file.path(dir, "example.svg") ) custom <- icon_set(dir) custom$exampledir <- tempfile() dir.create(dir) writeLines( '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M0 0"/></svg>', file.path(dir, "example.svg") ) custom <- icon_set(dir) custom$example
Customise the style of an icon
icon_style(x, scale = NULL, fill = NULL, rotate = NULL, ...)icon_style(x, scale = NULL, fill = NULL, rotate = NULL, ...)
x |
The icon to style. |
scale |
Scaled size of the icon. |
fill |
The colour for the fill. |
rotate |
The angle to rotate the icon. |
... |
Other CSS rules for the icon style, for example |
The input x (an icons vector), with its style updated to
reflect the requested styling.
path <- tempfile(fileext = ".svg") writeLines( '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M0 0"/></svg>', path ) icon <- read_icon(path) icon_style(icon, scale = 2, fill = "red", rotate = 90)path <- tempfile(fileext = ".svg") writeLines( '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M0 0"/></svg>', path ) icon <- read_icon(path) icon_style(icon, scale = 2, fill = "red", rotate = 90)
data: URIRenders an icon's SVG markup to a base64-encoded URI.
This enables self-contained and styled icon for consumers that use image
paths/URLs, including for example: an <img src>, a gt::html() cell,
and a leaflet marker iconUrl.
icon_uri(x)icon_uri(x)
x |
An |
A character vector giving each icon's base64 encoded URI.
path <- tempfile(fileext = ".svg") writeLines( '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M0 0"/></svg>', path ) icon_uri(read_icon(path))path <- tempfile(fileext = ".svg") writeLines( '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M0 0"/></svg>', path ) icon_uri(read_icon(path))
Read an individual icon
read_icon(x)read_icon(x)
x |
Path to the icon |
An icons vector: an SVG icon that can be printed, embedded
in R Markdown, or styled with icon_style(). If x is a file path, it
is retained and can be retrieved with icon_path().
path <- tempfile(fileext = ".svg") writeLines( '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M0 0"/></svg>', path ) read_icon(path)path <- tempfile(fileext = ".svg") writeLines( '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M0 0"/></svg>', path ) read_icon(path)