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 '../../component-library';
// etc...
```
### Size
Use the `size` prop and the `Size` object from `./ui/helpers/constants/design-system.js` to change the size of `Icon`. Defaults to `Size.SM`
Possible sizes include:
- `Size.XS` 12px
- `Size.SM` 16px
- `Size.MD` 20px
- `Size.LG` 24px
- `Size.XL` 32px
- `Size.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 '../../component-library';
inherits the
font-size of the parent element.
```
### Color
Use the `color` prop and the `Color` object from `./ui/helpers/constants/design-system.js` to change the color of `Icon`. Defaults to `Color.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 '../../component-library';
```
### Layout & Spacing
The `Icon` component accepts all [Box](/docs/components-ui-box--default-story#props) component props including `marginTop`, `marginRight`, ` marginBottom`, `marginLeft` which you can use directly to adjust the space between icons and other components like `Text`
Some examples of `Icon` with `Text` using [Box](/docs/components-ui-box--default-story#props) component props
```jsx
import {
AlignItems,
DISPLAY,
IconColor,
FLEX_DIRECTION,
BorderColor,
BorderRadius,
} from '../../../helpers/constants/design-system';
import Box from '../../ui/box/box';
import { ICON_NAMES, Icon, Text, Label } from '../../component-library';
Always allow you to opt-out via Settings
0x79fAaFe7B6D5DB5D8c63FE88DFF0AF1Fe53358db
Create account
{' '}
Warning
;
```
### 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.