Package 'phosphoricons'

Title: 'Phosphor' Icons for R
Description: Use 'Phosphor' icons in 'shiny' applications or 'rmarkdown' documents. Icons are available in 5 different weights and can be customized by setting color, size, orientation and more.
Authors: Victor Perrier [aut, cre, cph], Fanny Meyer [aut], Phosphor Icons [cph] (Phosphor Icons <https://github.com/phosphor-icons>)
Maintainer: Victor Perrier <[email protected]>
License: MIT + file LICENSE
Version: 0.2.1
Built: 2024-11-16 05:51:15 UTC
Source: https://github.com/dreamrs/phosphoricons

Help Index


HTML dependency for Phosphor Icons

Description

Allow to explicitly load dependency for using Phosphor icons.

Usage

html_dependency_phosphor()

Value

An htmltools::htmlDependency() object.

Note

Dependency is automatically loaded when using ph_i(), but in some case, like when using icon argument in some function, you might need to call html_dependency_phosphor() to make icons appears.

Examples

library(shiny)
library(phosphoricons)

ui <- navbarPage(
  title = "Phosphor Icons",
  header = list(
    html_dependency_phosphor()
  ),
  tabPanel("Home", icon = ph_i("house")),
  tabPanel("Parameters"),
  tabPanel("Results")
)

server <- function(input, output, session) {
  
}

if (interactive())
  shinyApp(ui, server)

Phosphor SVG Icons

Description

Create a ⁠<svg></svg>⁠ tag to render an icon.

Usage

ph(
  name,
  weight = c("light", "regular", "thin", "bold", "fill"),
  fill = "currentColor",
  rotate = NULL,
  height = "1.33em",
  width = NULL,
  vertical_align = "-0.25em",
  title = name,
  ...
)

Arguments

name

Name of the icon to use.

weight

Weight of icon (from thinnest to thickest): thin, light (default), regular, bold or fill.

fill

Fill color for the icon, default is currentColor which should match the color of the text where the icon is used.

rotate

Numeric, angle to rotate the icon.

height, width

Height and width in valid CSS unit.

vertical_align

Vertical alignment for the icon, this depend on the size of the icon.

title

Add a ⁠<title>⁠ tag to provides an accessible, short-text description of the icon. Use NULL for no title.

...

Attributes passed to the SVG tag.

Value

An SVG tag.

Examples

library(phosphoricons)

ph("airplane-tilt")
ph("airplane-tilt", weight = "thin")
ph("airplane-tilt", weight = "bold")
ph("house")
ph("house", fill = "#F45B69")
ph("cake", rotate = 45)
ph("airplane-tilt", height = 128)
ph("airplane-tilt", height = 128, weight = "fill")
ph("airplane-tilt", height = 128, weight = "fill", fill = "steelblue")

Fill SVG icon

Description

Fill an SVG icon with different colors according to breaks.

Usage

ph_fill(icon, colors, breaks, orientation = c("vertical", "horizontal"))

Arguments

icon

An icon generated with ph().

colors

Colors to fill icon with.

breaks

Breaks where to switch colors.

orientation

Orientation of color filling: vertical (from bottom to top), horizontal (from left to right).

Value

An SVG tag.

Examples

library(phosphoricons)
ph_fill(
  ph("heart", weight = "fill", height = 128),
  colors = c("#DF0101", "#F6CECE"),
  breaks = 0.7
)

ph_fill(
  ph("star", weight = "fill", height = 128, stroke = "gold", `stroke-width` = 10),
  colors = c("gold", "#FFF"),
  breaks = 0.5,
  orientation = "h"
)


# Multiple colors:
ph_fill(
  ph("trash", weight = "fill", height = 128),
  colors = c("forestgreen", "firebrick", "steelblue", "gold"),
  breaks = c(0.3, 0.6, 0.9)
)

Phosphor Font Icons

Description

Create a Phosphor icon with font files.

Usage

ph_i(
  name,
  weight = c("light", "regular", "thin", "bold", "fill"),
  size = c("lg", "xxs", "xs", "sm", "xl", "1x", "2x", "3x", "4x", "5x", "6x", "7x", "8x",
    "9x", "10x"),
  color = NULL,
  ...
)

Arguments

name

Name of the icon to use.

weight

Weight of icon (from thinnest to thickest): thin, light (default), regular, bold or fill.

size

Size of icon.

color

Color of icon: use valid HTML color or hex code.

...

Attributes passed to the i tag.

Value

An HTML tag.

Examples

library(phosphoricons)

ph_i("airplane-tilt")
ph_i("airplane-tilt", weight = "thin")
ph_i("airplane-tilt", weight = "bold")
ph_i("house")
ph_i("house", color = "#F45B69")
ph_i("cake")
ph_i("cake", size = "xl")
ph_i("cake", size = "10x")

Search Icons

Description

Search Icons

Usage

search_icon(pattern, output = c("viewer", "console"))

Arguments

pattern

Pattern to search for in icon's name.

output

View results in the viewer or in the console.

Value

If output = "console" a character vector, if output = "viewer" a shiny.tag.

Examples

search_icon("calendar")
search_icon("text")

Waffle plot with icons

Description

Waffle plot with icons

Usage

waffle_icon(
  values,
  colors,
  icons,
  ncol = 10,
  nrow = 10,
  flow = c("row", "column"),
  legend = TRUE,
  width = NULL
)

Arguments

values

A vector of values to be plotted.

colors

Colors to use for each unique values.

icons

Icon or list of icons associated to unique values.

ncol, nrow

Number of column and row in the matrix.

flow

Populate matrix by rows or columns.

legend

Logical, display or not a legend.

width

Width of the matrix.

Value

HTML tags.

Examples

library(phosphoricons)

waffle_icon(
  values = sort(sample(c("Aa", "Bb", "Cc"), 100, TRUE)),
  colors = c("#81F4E1", "#56CBF9", "#FF729F"),
  icons = ph("user", weight = "fill", height = 32)
)

waffle_icon(
  values = sample(c("Cats", "Dogs"), 200, TRUE),
  colors = list(
    Cats = "#456990",
    Dogs = "#F45B69"
  ),
  icons = list(
    Cats = ph("cat", height = NULL),
    Dogs = ph("dog", height = NULL)
  ),
  ncol = 15,
  nrow = 8,
  width = "500px"
)