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/ui-components-ui-box-box-stories-js--default-story#props) component props ### Name Use the `name` prop and the `ICON_NAMES` object to change the icon. Use the [IconSearch](/ui-components-component-library-icon-icon-stories-js--name) story to find the icon you want to use. ```jsx import { Icon, ICON_NAMES } from '../ui/component-library'; ``` ### 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.XXS` 10px - `SIZES.XS` 12px - `SIZES.SM` 16px - `SIZES.MD` 20px - `SIZES.LG` 24px - `SIZES.XL` 32px ```jsx import { SIZES } from '../../../helpers/constants/design-system'; import { Icon, ICON_NAMES } from '../ui/component-library'; ``` ### 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 { COLORS } from '../../../helpers/constants/design-system'; import { Icon, ICON_NAMES } from '../ui/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` and ensure the icon name starts with `icon-` e.g. `icon-add-square-filled.svg` #### 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.