import { Story, Canvas, ArgsTable } from '@storybook/addon-docs'; import { Icon } from './icon'; # Icon The `Icon` component in conjunction with `ICON_NAMES` can be used for all icons in the extension ## Props The `Icon` accepts all props below as well as all [Box](/docs/components-ui-box--default-story#props) component props ### Name Use the `name` prop and the `ICON_NAMES` object to change the icon. Use the [IconSearch](/story/components-componentlibrary-icon--default-story) story to find the icon you want to use. ```jsx import { Icon, ICON_NAMES } from '../../components/component-library'; // etc... ``` ### Size Use the `size` prop and the `SIZES` object from `./ui/helpers/constants/design-system.js` to change the size of `Icon`. Defaults to `SIZES.SM` Possible sizes include: - `SIZES.XS` 12px - `SIZES.SM` 16px - `SIZES.MD` 20px - `SIZES.LG` 24px - `SIZES.XL` 32px - `SIZES.INHERIT` inherits the font-size from parent element. This is useful for inline icons in text. ```jsx import { Size,TextVariant } from '../../../helpers/constants/design-system'; import { Icon, ICON_NAMES } from '../../components/component-library'; inherits the font-size of the parent element. ``` ### Color Use the `color` prop and the `COLORS` object from `./ui/helpers/constants/design-system.js` to change the color of `Icon`. Defaults to `COLORS.INHERIT` which will use the text color of the parent element. This is useful for inline icons. ```jsx import { IconColor } from '../../../helpers/constants/design-system'; import { Icon, ICON_NAMES } from '../../components/component-library'; ``` ### Adding a new icon To add a new icon the only thing you need to do is add the icon svg file to `app/images/icons`. To ensure that the icon is added correctly follow these steps: #### Step 1. Optimize the svg using [Fontastic](https://fontastic.me/). This will remove any unnecessary code from the svg. Your svg should only contain a single path. Example of a correctly optimized svg: ``` ``` If your svg **does not** contain a single path, you will need to get a designer to join all paths and outline strokes into a single path. #### Step 2. Add your optimized svg file to to `app/images/icons` #### Step 3. Run `yarn start` to generate the `ICON_NAMES` with your added icon. If you have any questions please reach out to the design system team in the [#metamask-design-system](https://consensys.slack.com/archives/C0354T27M5M) channel on slack.