Icon libraries aren’t bundled with the package, keeping it small and letting you choose which version of each library you use. Download the ones you want once per machine:
icon_installed() tells you whether a library has already
been downloaded:
The rest of this vignette uses Font Awesome; swap in any other set
(ionicons, academicons,
simple_icons, google_material,
octicons, feather_icons,
bioicons, super_tiny_icons) the same way.
Icons can be inserted inline,
e.g. `r fontawesome("rocket", style = "solid")`, or from a
code chunk:
The same icon can be accessed with $, which is handy for
tab-completion:
If a name isn’t a valid R name (e.g. it contains a -),
quote it:
icon_style() customises an icon’s appearance:
It accepts scale, fill and
rotate, plus any other CSS property via ...
(for example float = "right").
Any folder of SVG files can become an icon set with
icon_set(), which is useful for icons that aren’t from a
supported library (including Font Awesome Pro icons):
icon_dir <- tempfile()
dir.create(icon_dir)
writeLines(
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 2 L22 22 L2 22 Z"/></svg>',
file.path(icon_dir, "triangle.svg")
)
custom <- icon_set(icon_dir)
custom$triangleicon_save() does the reverse: it bundles icons you’re
already using into a folder, so a shared document or deployed app
doesn’t need the original library installed:
Not sure which library has the icon you want, or what it’s called? Search everything you have installed: