GitHub Octicons
Octicons are a scalable set of icons handcrafted with <3 by GitHub.
Install
NOTE: The compiled files are located in build/
. This directory is located in the published npm package. Which means you can access it when you npm install octicons
. You can also build this directory by following the building octicons directions. The files in the lib/
directory are the raw source files and are not compiled or optimized.
npm
This repository is distributed with npm. After installing npm, you can install octicons
with this command.
$ npm install @primer/octicons --save
Usage
For all the usages, we recommend using the CSS located in build/build.css
. This is some simple CSS to normalize the icons and inherit colors.
Node
After installing npm install octicons
you can access the icons like this.
var octicons = require("octicons")
octicons.alert
There will be a key for every icon, with toSVG
and other properties.
octicons.alert.symbol
Returns the string of the symbol name, same as the key for that icon.
octicons.x.symbol
octicons.person.path
Returns the string representation of the path of the icon.
octicons.x.path
octicons.issue.options
This is an object of all the attributes that will be added to the output tag.
octicons.x.options
octicons.alert.width
Returns the icon's true width, based on the svg view box width. Note, this doesn't change if you scale it up with size options, it only is the natural width of the icon.
octicons.alert.height
Returns the icon's true height, based on the svg view box height. Note, this doesn't change if you scale it up with size options, it only is the natural height of the icon.
keywords
Returns an array of keywords for the icon. The data comes from the data file in lib. Consider contributing more aliases for the icons.
octicons.x.keywords
octicons.alert.toSVG()
Returns a string of the <svg>
tag.
octicons.x.toSVG()
The .toSVG()
method accepts an optional options
object. This is used to add CSS classnames, a11y options, and sizing.
class
Add more CSS classes to the <svg>
tag.
octicons.x.toSVG({ "class": "close" })
aria-label
Add accessibility aria-label
to the icon.
octicons.x.toSVG({ "aria-label": "Close the window" })
width & height
Size the SVG icon larger using width
& height
independently or together.
octicons.x.toSVG({ "width": 45 })
License
(c) GitHub, Inc.
When using the GitHub logos, be sure to follow the GitHub logo guidelines.
MIT