---
title: JavaScript
status: Stable
source: 'https://github.com/primer/octicons/tree/main/lib/octicons_node'
---
[![npm version](https://img.shields.io/npm/v/@primer/octicons.svg)](https://www.npmjs.org/package/@primer/octicons)
## Install
This package is distributed with [npm][npm]. After [installing npm][install-npm], you can install `@primer/octicons` with this command:
```shell
npm install @primer/octicons
```
## Usage
For all the usages, we recommend using the CSS located in [`build/build.css`](https://unpkg.com/@primer/octicons/build/build.css). This is some simple CSS to normalize the icons and inherit colors.
After installing `@primer/octicons` you can access the icons like this:
```js
var octicons = require("@primer/octicons")
octicons.alert
// {
// symbol: 'alert',
// keywords: ['warning', 'triangle', 'exclamation', 'point'],
// toSVG: [Function]
// heights: {
// 16: {
// width: 16,
// path: '',
// options: {
// version: '1.1',
// width: '16',
// height: '16',
// viewBox: '0 0 16 16',
// class: 'octicon octicon-alert',
// 'aria-hidden': 'true'
// },
// },
// 24: ...
// }
// }
```
There will be a key for every icon, with [`toSVG`](#octiconsnametosvg) and other properties.
_Note: `alert` in the above example can be replaced with any valid icon name. Icons with multi-word names (e.g. `arrow-right`) **cannot** be accessed using dot notation (e.g. `octicons.alert`). Instead, use bracket notation (e.g. `octicons['arrow-right']`)._
### `octicons[name].symbol`
Returns the string of the symbol name, same as the key for that icon.
```js
octicons.x.symbol
// "x"
```
### `octicons[name].keywords`
Returns an array of keywords for the icon. The data comes from [keywords.json](https://github.com/primer/octicons/blob/main/keywords.json). Consider contributing more aliases for the icons.
```js
octicons.x.keywords
// ["remove", "close", "delete"]
```
### `octicons[name].heights`
Each icon can have multiple SVGs that are designed for different sizes. The `heights` property allows you to access all the SVGs for an icon using the natural height of the SVG.
```js
octicons.x.heights
// {
// 16: {
// width: 16,
// path: '',
// options: {
// version: '1.1',
// width: '16',
// height: '16',
// viewBox: '0 0 16 16',
// class: 'octicon octicon-alert',
// 'aria-hidden': 'true'
// },
// },
// 24: {
// width: 24,
// path: '',
// options: {
// version: '1.1',
// width: '24',
// height: '24',
// viewBox: '0 0 24 24',
// class: 'octicon octicon-alert',
// 'aria-hidden': 'true'
// },
// },
// }
```
### `octicons[name].heights[height].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[name].heights[height].path`
Returns the string representation of the path of the icon.
```js
octicons.x.heights[16].path
//
```
### `octicons[name].heights[height].options`
This is an object of all the attributes that will be added to the output tag.
```js
octicons.x.heights[16].options
// { version: '1.1', width: '12', height: '16', viewBox: '0 0 12 16', class: 'octicon octicon-x', 'aria-hidden': 'true' }
```
### `octicons[name].toSVG()`
Returns a string of the `