toString()
This function is part of IconSet class in Iconify Tools.
Function toString() exports icon as string.
Usage
Function has the following parameters:
- name, string. Icon name.
- customisations, IconifyIconCustomisations. Optional list of customisations.
Function returns rendered icon as string on success, null if icon does not exist.
Customisations
If customisations is not set, default value is:
json
{
"width": "auto",
"height": "auto"
}
which results in width and height of icon matching viewBox (see example below).
If you want to use 1em height, use the following customisations:
json
{
"height": "1em"
}
Example
example.ts
ts
import { blankIconSet } from '@iconify/tools';
const iconSet = blankIconSet('');
iconSet.setIcon('add', {
body: '<g fill="currentColor"><path d="M14 7v1H8v6H7V8H1V7h6V1h1v6h6z"/></g>',
});
// Export icon
console.log(iconSet.toString('add'));
Result:
svg
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" preserveAspectRatio="xMidYMid meet" viewBox="0 0 16 16"><g fill="currentColor"><path d="M14 7v1H8v6H7V8H1V7h6V1h1v6h6z"/></g></svg>