import { Story, Canvas, ArgsTable } from '@storybook/addon-docs';
import { Icon } from './icon';
# Icon
The `Icon` component in conjunction with `IconName` 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 `IconName` enum 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, IconName } from '../../component-library';
// etc...
```
### Size
Use the `size` prop and the `IconSize` enum to change the size of `Icon`. Defaults to `IconSize.Sm`
Possible sizes include:
- `IconSize.Xs` 12px
- `IconSize.Sm` 16px
- `IconSize.Md` 20px
- `IconSize.Lg` 24px
- `IconSize.Xl` 32px
- `IconSize.Inherit` inherits the font-size from parent element. This is useful for inline icons in text.
```jsx
import { TextVariant } from '../../../helpers/constants/design-system';
import { Icon, IconName, IconSize, Text } from '../../component-library';
inherits the
font-size of the parent element.
```
### Color
Use the `color` prop and the `IconColor` enum from `./ui/helpers/constants/design-system.js` to change the color of `Icon`. Defaults to `IconColor.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, IconName } 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,
FlexDirection,
BorderColor,
BorderRadius,
} from '../../../helpers/constants/design-system';
import Box from '../../ui/box/box';
import { IconName, Icon, IconSize, Text, Label } from '../../component-library';
Always allow you to opt-out via Settings
0x79fAaFe7B6D5DB5D8c63FE88DFF0AF1Fe53358db
Create account
{' '}
Warning
;
```
### Adding a new icon
In order to ensure that a new icon is added correctly, there are a few steps that need to be followed:
#### 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 `add-square-filled.svg`:
```xml
```
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.
Add your icon to the `IconName` enum in `./ui/components/ui/icon/icon.types.ts`
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.