Pictograms
Carbon pictograms are provided through a set of packages allowing the use of pictograms in multiple frameworks. Pictograms are supported in vanilla, React, Angular, and Vue.
Get started
To install
@carbon/pictograms-react
npm install -S @carbon/pictograms-react
If you prefer Yarn, use the following command instead:
yarn add @carbon/pictograms-react
Usage
You can import a pictogram component into your project by referring to its name:
import { Airplane } from '@carbon/pictograms-react';
We also provide CommonJS and UMD files in the
lib
umd
To import using CommonJS, you can do the following:
const { Airplane } = require('@carbon/pictograms-react');
Note: if you would like to find the import path for a pictogram, you can reference our Pictogram Library
Icon fill
All icons from the library support being styled by the
fill
// CSS custom class name to set the fill of the icon to `rebeccapurple`svg.my-custom-class {fill: rebeccapurple;}
import { Airplane } from '@carbon/pictograms-react';function MyComponent() {return (<button><Airplane aria-label="Add" className="my-custom-class" /></button>);}
Focus and aria-label
aria-label
By default, the icon components from
@carbon/pictograms-react
aria-hidden="true"
If you would like the icon to be announced by a screen reader, you can supply an
aria-label
aria-labelledby
import { Airplane } from '@carbon/pictograms-react';function MyComponent() {return (<button><Airplane aria-label="Add" /></button>);}
Doing this will add the appropriate
role
<svg>
If you would like the
<svg>
tabIndex
import { Airplane } from '@carbon/pictograms-react';function MyComponent() {return <Airplane aria-label="Add" tabIndex="0" />;}
Including
tabIndex
aria-label
aria-labelledby
tabindex
<svg>
focusable
true