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 |
Allow to explicitly load dependency for using Phosphor icons.
html_dependency_phosphor()
html_dependency_phosphor()
An htmltools::htmlDependency()
object.
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.
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)
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)
Create a <svg></svg>
tag to render an icon.
ph( name, weight = c("light", "regular", "thin", "bold", "fill"), fill = "currentColor", rotate = NULL, height = "1.33em", width = NULL, vertical_align = "-0.25em", title = name, ... )
ph( name, weight = c("light", "regular", "thin", "bold", "fill"), fill = "currentColor", rotate = NULL, height = "1.33em", width = NULL, vertical_align = "-0.25em", title = name, ... )
name |
Name of the icon to use. |
weight |
Weight of icon (from thinnest to thickest): |
fill |
Fill color for the icon, default is |
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 |
... |
Attributes passed to the SVG tag. |
An SVG tag.
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")
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 an SVG icon with different colors according to breaks.
ph_fill(icon, colors, breaks, orientation = c("vertical", "horizontal"))
ph_fill(icon, colors, breaks, orientation = c("vertical", "horizontal"))
icon |
An icon generated with |
colors |
Colors to fill icon with. |
breaks |
Breaks where to switch colors. |
orientation |
Orientation of color filling: |
An SVG tag.
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) )
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) )
Create a Phosphor icon with font files.
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, ... )
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, ... )
name |
Name of the icon to use. |
weight |
Weight of icon (from thinnest to thickest): |
size |
Size of icon. |
color |
Color of icon: use valid HTML color or hex code. |
... |
Attributes passed to the |
An HTML tag.
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")
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
search_icon(pattern, output = c("viewer", "console"))
search_icon(pattern, output = c("viewer", "console"))
pattern |
Pattern to search for in icon's name. |
output |
View results in the viewer or in the console. |
If output = "console"
a character vector, if output = "viewer"
a shiny.tag
.
search_icon("calendar") search_icon("text")
search_icon("calendar") search_icon("text")
Waffle plot with icons
waffle_icon( values, colors, icons, ncol = 10, nrow = 10, flow = c("row", "column"), legend = TRUE, width = NULL )
waffle_icon( values, colors, icons, ncol = 10, nrow = 10, flow = c("row", "column"), legend = TRUE, width = NULL )
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. |
HTML tags.
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" )
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" )