All Projects → phosphor-icons → Phosphor React

phosphor-icons / Phosphor React

Licence: mit
A flexible icon family for React

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Phosphor React

Phosphor Icons
A flexible icon family for the web
Stars: ✭ 56 (-42.27%)
Mutual labels:  svg, icons, svg-icons, icon-font, icon-pack
Boxicons
High Quality web friendly icons
Stars: ✭ 1,104 (+1038.14%)
Mutual labels:  svg, icons, svg-icons, icon-font, icon-pack
Coreui Icons
CoreUI Free Icons - Premium designed free icon set with marks in SVG, Webfont and raster formats
Stars: ✭ 1,813 (+1769.07%)
Mutual labels:  svg, icons, svg-icons, icon-font, icon-pack
Simple Icons
SVG icons for popular brands
Stars: ✭ 12,090 (+12363.92%)
Mutual labels:  svg, icons, svg-icons, icon-pack
Tabler Icons
A set of over 1400 free MIT-licensed high-quality SVG icons for you to use in your web projects.
Stars: ✭ 10,858 (+11093.81%)
Mutual labels:  svg, icons, svg-icons, icon-pack
Vue Unicons
1000+ Pixel-perfect svg icons for your next project as Vue components
Stars: ✭ 828 (+753.61%)
Mutual labels:  svg, icons, svg-icons, icon-pack
Icons
The premium icon font for @uiwjs Component Library. https://uiwjs.github.io/icons
Stars: ✭ 99 (+2.06%)
Mutual labels:  svg, icons, svg-icons, icon-font
Circle Flags
A collection of 300+ minimal circular SVG country flags
Stars: ✭ 139 (+43.3%)
Mutual labels:  svg, icons, svg-icons, icon-pack
Icons Flat Osx
Free Flat icons For OSX
Stars: ✭ 366 (+277.32%)
Mutual labels:  icons, svg-icons, icon-pack
Jam
Jam icons is a set of SVG icons designed for web projects, illustrations, print projects, etc. Licensed under MIT
Stars: ✭ 398 (+310.31%)
Mutual labels:  svg, icons, svg-icons
Evil Icons
Simple and clean SVG icon pack with the code to support Rails, Sprockets, Node.js, Gulp, Grunt and CDN
Stars: ✭ 4,944 (+4996.91%)
Mutual labels:  svg, icons, svg-icons
Bytesize Icons
Tiny style-controlled SVG iconset (101 icons, 12kb)
Stars: ✭ 3,662 (+3675.26%)
Mutual labels:  svg, icons, svg-icons
Ikonate
Fully customisable & accessible vector icons
Stars: ✭ 3,392 (+3396.91%)
Mutual labels:  svg, icons, icon-pack
Remixicon
Open source neutral style icon system
Stars: ✭ 3,956 (+3978.35%)
Mutual labels:  svg, icon-font, icon-pack
Phosphor Home
The homepage of Phosphor Icons, a flexible icon family for everyone
Stars: ✭ 704 (+625.77%)
Mutual labels:  icons, icon-font, icon-pack
Browser Logos
🗂 High resolution web browser logos
Stars: ✭ 5,538 (+5609.28%)
Mutual labels:  svg, icons, svg-icons
Grayshift
A lightweight front-end component library for developing fast and powerful web interfaces.
Stars: ✭ 304 (+213.4%)
Mutual labels:  svg, icons, svg-icons
Icons
All SVG icons available on http://game-icons.net
Stars: ✭ 598 (+516.49%)
Mutual labels:  svg, icons, svg-icons
Svgsprit.es
Public endpoint to generate SVG Sprites
Stars: ✭ 73 (-24.74%)
Mutual labels:  svg, icons, svg-icons
Mono Icons
Stars: ✭ 899 (+826.8%)
Mutual labels:  svg, icons, svg-icons

phosphor-react

Phosphor is a flexible icon family for interfaces, diagrams, presentations — whatever, really. Explore all our icons at phosphoricons.com.

NPM JavaScript Style Guide Travis

GitHub stars GitHub forks GitHub watchers Follow on GitHub

Installation

yarn add phosphor-react

or

npm install --save phosphor-react

Usage

Simply import the icons you need, and add them anywhere in your render method. Phosphor supports tree-shaking, so your bundle only includes code for the icons you use.

import React from "react";
import ReactDOM from "react-dom";
import { Horse, Heart, Cube } from "phosphor-react";

const App = () => {
  return (
    <div>
      <Horse />
      <Heart color="#AE2983" weight="fill" size={32} />
      <Cube color="teal" weight="duotone" />
    </div>
  );
};

ReactDOM.render(<App />, document.getElementById("root"));

Props

Icon components accept all props that you can pass to a normal SVG element, including inline style objects, onClick handlers, and more. The main way of styling them will usually be with the following props:

  • color?: string – Icon stroke/fill color. Can be any CSS color string, including hex, rgb, rgba, hsl, hsla, named colors, or the special currentColor variable.
  • size?: number | string – Icon height & width. As with standard React elements, this can be a number, or a string with units in px, %, em, rem, pt, cm, mm, in.
  • weight?: "thin" | "light" | "regular" | "bold" | "fill" | "duotone" – Icon weight/style. Can also be used, for example, to "toggle" an icon's state: a rating component could use Stars with weight="regular" to denote an empty star, and weight="fill" to denote a filled star.
  • mirrored?: boolean – Flip the icon horizontally. Can be useful in RTL languages where normal icon orientation is not appropriate.

Context

Phosphor takes advantage of React Context to make applying a default style to all icons simple. Create an IconContext.Provider at the root of the app (or anywhere above the icons in the tree) and pass in a configuration object with props to be applied by default to all icons:

import React from "react";
import ReactDOM from "react-dom";
import { IconContext, Horse, Heart, Cube } from "phosphor-react";

const App = () => {
  return (
    <IconContext.Provider
      value={{
        color: "limegreen",
        size: 32,
        weight: "bold",
        mirrored: false,
      }}
    >
      <div>
        <Horse /> {/* I'm lime-green, 32px, and bold! */}
        <Heart /> {/* Me too! */}
        <Cube />  {/* Me three :) */}
      </div>
    </IconContext.Provider>
  );
};

ReactDOM.render(<App />, document.getElementById("root"));

You may create multiple Contexts for styling icons differently in separate regions of an application; icons use the nearest Context above them to determine their style.

Note: The color, size, weight, and mirrored properties are all required props when creating a context.

Composability

Components can accept arbitrary SVG elements as children, so long as they are valid children of the <svg> element. This can be used to modify an icon with background layers or shapes, filters, animations and more. The children will be placed below the normal icon contents.

The following will cause the Cube icon to rotate and pulse:

const RotatingCube = () => {
  return (
    <Cube color="darkorchid" weight="duotone">
      <animate
        attributeName="opacity"
        values="0;1;0"
        dur="4s"
        repeatCount="indefinite"
      ></animate>
      <animateTransform
        attributeName="transform"
        attributeType="XML"
        type="rotate"
        dur="5s"
        from="0 0 0"
        to="360 0 0"
        repeatCount="indefinite"
      ></animateTransform>
    </Cube>
  );
};

Note: The coordinate space of slotted elements is relative to the contents of the icon viewBox, which is a 256x256 square. Only valid SVG elements will be rendered.

Imports

You may wish to import all icons at once for use in your project, though depending on your bundler this could prevent tree-shaking and make your app's bundle larger.

import * as Icon from "phosphor-react";
...
<Icon.Smiley />
<Icon.Folder weight="thin" />
<Icon.BatteryHalf size="24px" />

Related Projects

License

MIT © Phosphor Icons

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].