Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mitchelloharawild/icons
R package to easily insert web icons to RMarkdown
https://github.com/mitchelloharawild/icons
fontawesome icon-library ozunconf17 r unconf web-icons
Last synced: 6 days ago
JSON representation
R package to easily insert web icons to RMarkdown
- Host: GitHub
- URL: https://github.com/mitchelloharawild/icons
- Owner: mitchelloharawild
- Created: 2017-10-27T02:37:33.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-08-12T01:04:57.000Z (over 1 year ago)
- Last Synced: 2024-12-30T03:16:48.522Z (13 days ago)
- Topics: fontawesome, icon-library, ozunconf17, r, unconf, web-icons
- Language: R
- Homepage: https://pkg.mitchelloharawild.com/icons
- Size: 3.13 MB
- Stars: 314
- Watchers: 9
- Forks: 43
- Open Issues: 15
-
Metadata Files:
- Readme: README.Rmd
Awesome Lists containing this project
- jimsghstars - mitchelloharawild/icons - R package to easily insert web icons to RMarkdown (R)
README
---
output: github_document
---```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/"
)
```[![R-CMD-check](https://github.com/mitchelloharawild/icons/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/mitchelloharawild/icons/actions/workflows/R-CMD-check.yaml)
[![Coverage status](https://codecov.io/gh/mitchelloharawild/icons/branch/master/graph/badge.svg)](https://codecov.io/gh/mitchelloharawild/icon?branch=master)
[![lifecycle](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)
[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/icon)](https://cran.r-project.org/package=icons)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:
* [Font Awesome](https://github.com/FortAwesome/Font-Awesome/) (Pro icons can be used using custom icon sets)
* [Ionicons](https://github.com/ionic-team/ionicons/)
* [Academicons](https://github.com/jpswalsh/academicons)
* [Simple Icons](https://github.com/simple-icons/simple-icons/)
* [Google's Material Design](https://github.com/google/material-design-icons)
* [Octicons](https://github.com/primer/octicons)
* [Feather Icons](https://github.com/feathericons/feather)
* [Bioicons](https://github.com/duerrsimon/bioicons)# Installation
The **development** version can be installed from GitHub using:
```{r gh-installation, eval = FALSE}
# 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
```{r load}
library(icons)
```Icons can be inserted inline using inline code `` `r knitr::inline_expr('icons::fontawesome("rocket", style = "solid")')` `` `r icons::fontawesome("rocket", style = "solid")` or `` `r knitr::inline_expr('icons::fontawesome$solid$rocket')` `` `r icons::fontawesome$solid$rocket`.
Icons can also be inserted using usual R chunks.
````
```{r icon-chunk}`r ''`
fontawesome("rocket", style = "solid") # equivalent to icons::fontawesome$solid$rocket
```
````
```{r icon-chunk, echo=FALSE}
fontawesome("rocket", style = "solid")
```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:
```{r icon-syntax}
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}`r ''`
icon_style(fontawesome("rocket", style = "solid"), scale = 2, fill = "red")
```
````
```{r icon-style, echo=FALSE}
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}`r ''`
custom <- icons::icon_set("hex")
custom$icons
```
```````{r icon-custom, echo=FALSE}
custom <- icon_set("hex")
custom$icons
```You can also search for icons using the `icon_find()` function.
```{r icon-find}
icon_find("rocket")
```# A Note on the old API
This is the second iteration of the icon package, the [first icon package](https://github.com/ropenscilabs/icon) has been successful, but lacked a few features such as SVG icons, user defined libraries, and extensibility support. You can read the notes on the new API [here](https://github.com/ropenscilabs/icon/issues/19). It turns out that it was easier to build the new and improved icon from scratch, which is what this repository is. In the future this version of icon might just be merged into rOpenScilabs/icon, but for the mean time it will be developed here. We anticipate that there will only be any minor changes to the existing API, so hopefully this will be a seamless transition for users! Notably, the `icon_name` functions have been removed in favour of `icon$name`, and the interface for styling and animating has been removed/changed.
If you need to use the first version of the package that was developed from the rOpenSci hackathon, you can install it with `remotes::install_github("mitchelloharawild/[email protected]")`.