Calcite includes an iconset known as Calcite UI Icons. To make these icons easier to use in React, we use a library (calcite-ui-icons-react) that creates React components from the SVG icons.
To use these icons, you must install the calcite-ui-icons-react
package:
The name of the React component you will import is simply the icon name in PascalCase suffixed with Icon
.
The icons take an optional size
prop to adjust the rendered size of the icon.
Calcite UI Icons has three unique SVGs for varying sizes for every icon, and we
automatically select an icon for you based on the size you specify.
All icons accept a color prop, which will be applied to the fill attribute on
the svg
element. This means any valid CSS color value can be used
(e.g. "red", "#e34f2c", "rgba(255, 0, 0, 0.5)"). If a color prop is not found,
we will set it to "currentColor".
Since JavaScript variables cannot start with a number, we convert any icon name that begins with a number so that the word (or words, in PascalCase) are used instead.
Currently, there are only two such cases:
Calcite UI Icons name | React Component Name |
---|---|
2d-explore | TwoDExplore |
3d-glasses | ThreeDGlasses |