icon-customisations
title: IconifyIconCustomisations Type
types:
IconifyIconSize: './icon-customisations.md#icon-size'
functions:
defaultIconCustomisations: './default-icon-customisations.md'
iconToSVG: './icon-to-svg.md'
mergeCustomisations: './merge-customisations.md'
IconifyIconCustomisations type
[type]IconifyIconCustomisations type is used in Iconify Utils in functions for generating SVG.
You can find this type in [file]src/customisations/defaults.ts of Iconify Utils source code.
Type is an object, with the following properties, split into groups:
Dimensions {#icon-size}
Icon dimensions, which has type [type]IconifyIconSizeCustomisations, have 2 properties:
[prop]width,[type]IconifyIconSizeicon width.[prop]height,[type]IconifyIconSizeicon height.
Type [type]IconifyIconSize is alias for [type]null | string | number. Possible values are:
[type]numbernumber in pixels.[type]stringnumber with units, such as[str]1em.
There are several special keywords:
[str]autosets dimension to value from icon's[attr]viewBox. So if icon has[attr]viewBox="0 0 24 24", setting[prop]widthto[str]autosets it to[num]24.[str]unsetand[str]nonetell function to skip attribute. This makes it easy to use[prop]widthand[prop]heightin CSS.
When calculating icon dimensions, setting one dimension (usually [attr]height) is enough. Another dimension will be automatically calculated using icon's proportions.
If both [prop]width and [prop]height are not set or null, by default [prop]height will be set to [str]1em.
Transformations
Icon can be transformed. Transformations are done by rotating or flipping content inside SVG, these are not CSS transformations. Properties for transforming icon:
[prop]hFlip,[type]boolean. Flips icon horizontally.[prop]vFlip,[type]boolean. Flips icon vertically.[prop]rotate,[type]number. Rotates icon in 90 degrees steps.[num]1is[prop]90deg,[num]2is[prop]180deg,[num]3is[prop]270deg. Rotation is limited only to these angles because these angles guarantee that icon content does not go beyond[prop]viewBoxboundaries. If you want to rotate using different angle, use CSS rotation that rotates an entire icon with bounding box.
If you want to pick only transformations from customisations, use type [type]IconifyTransformations.
FullIconifyIconCustomisations type
Type [type]FullIconifyIconCustomisations is the same as [type]IconifyIconCustomisations, but all properties are required.
Use [func]defaultIconCustomisations constant to get all default values and merged it with your values:
src: libraries/utils/icon-customisations.ts
title: 'example.ts'
Then result can be used with [func]mergeCustomisations() function.
Also see [func]defaultIconCustomisations constant.
谢谢你的反馈!