@wordpress/components
Version:
UI components for WordPress.
46 lines • 1.58 kB
TypeScript
/**
* External dependencies
*/
import type { ComponentType, SVGProps } from 'react';
import type { IconKey as DashiconIconKey } from '../dashicon/types';
export type IconType = DashiconIconKey | ComponentType<{
size?: number;
}> | ((props: {
size?: number;
}) => JSX.Element) | JSX.Element;
type AdditionalProps<T> = T extends ComponentType<infer U> ? U : T extends DashiconIconKey ? SVGProps<SVGSVGElement> : {};
export type Props = {
/**
* The icon to render. In most cases, you should use an icon from
* [the `@wordpress/icons` package](https://wordpress.github.io/gutenberg/?path=/story/icons-icon--library).
*
* Other supported values are: component instances, functions,
* [Dashicons](https://developer.wordpress.org/resource/dashicons/)
* (specified as strings), and `null`.
*
* The `size` value, as well as any other additional props, will be passed through.
*
* @default null
*/
icon?: IconType | null;
/**
* The size (width and height) of the icon.
*
* Defaults to `20` when `icon` is a string (i.e. a Dashicon id), otherwise `24`.
*
* @default `'string' === typeof icon ? 20 : 24`.
*/
size?: number;
} & AdditionalProps<IconType>;
/**
* Renders a raw icon without any initial styling or wrappers.
*
* ```jsx
* import { wordpress } from '@wordpress/icons';
*
* <Icon icon={ wordpress } />
* ```
*/
declare function Icon({ icon, size, ...additionalProps }: Props): import("react").JSX.Element | null;
export default Icon;
//# sourceMappingURL=index.d.ts.map