FullIconifyIcon type
FullIconifyIcon type is used in Iconify Utils to handle icon data.
You can find this type in src/icon/index.ts of Iconify Utils source code.
This type is identical to IconifyIcon, except that all properties are mandatory.
ts
import type { IconifyIcon } from '@iconify/types';
export type FullIconifyIcon = Required<IconifyIcon>;
See IconifyIcon type for details.
Example
json
{
"body": "<path d=\"M7 6v12l10-6z\" fill=\"currentColor\"/>",
"left": 0,
"top": 0,
"width": 24,
"height": 24,
"rotate": 0,
"vFlip": false,
"hFlip": false
}
Usage
To convert IconifyIcon to FullIconifyIcon, merge defaultIconProps with your data:
usage.ts
ts
import type { IconifyIcon, FullIconifyIcon } from '@iconify/utils';
import { defaultIconProps } from '@iconify/utils';
// Icon
const icon: IconifyIcon = {
body: '<path d="M7 6v12l10-6z" fill="currentColor"/>',
width: 24,
height: 24,
};
// Add all optional properties
const fullIcon: FullIconifyIcon = {
// Default values first
...defaultIconProps,
// Then custom values to override default values
...icon,
};
console.log(fullIcon);
Result:
json
{
"left": 0,
"top": 0,
"width": 24,
"height": 24,
"rotate": 0,
"vFlip": false,
"hFlip": false,
"body": "<path d=\"M7 6v12l10-6z\" fill=\"currentColor\"/>"
}