@wordpress/components
Version:
UI components for WordPress.
83 lines (57 loc) • 1.48 kB
Markdown
Allows you to render a raw icon without any initial styling or wrappers.
```jsx
import { Icon } from '@wordpress/components';
const MyIcon = () => <Icon icon="screenoptions" />;
```
```jsx
import { Icon } from '@wordpress/components';
const MyIcon = () => (
<Icon
icon={ () => (
<svg>
<path d="M5 4v3h5.5v12h3V7H19V4z" />
</svg>
) }
/>
);
```
```jsx
import { MyIconComponent } from '../my-icon-component';
import { Icon } from '@wordpress/components';
const MyIcon = () => <Icon icon={ MyIconComponent } />;
```
```jsx
import { Icon } from '@wordpress/components';
const MyIcon = () => (
<Icon
icon={
<svg>
<path d="M5 4v3h5.5v12h3V7H19V4z" />
</svg>
}
/>
);
```
```jsx
import { Icon } from '@wordpress/components';
const MyIcon = () => <Icon icon="screenoptions" className="example-class" />;
```
The component accepts the following props. Any additional props are passed through to the underlying icon element.
The icon to render. Supported values are: Dashicons (specified as strings), functions, WPComponent instances and `null`.
- Type: `String|Function|WPComponent|null`
- Required: No
- Default: `null`
The size (width and height) of the icon.
- Type: `Number`
- Required: No
- Default: `20` when a Dashicon is rendered, `24` for all other icons.