Style
/ API Reference / PluginsStyle
/ API Reference / Pluginsunit
This plugin converts numeric values to the given unit.
It is aware of unitless properties such as line-height, zero-values and also adds units to multiple values inside an array.
The Gist
import { unitPlugin } from '@weser/style'
const plugin = unitPlugin('px', {
fontSize: 'rem',
})
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| defaultUnit | string | 'px' | The global unit that gets applied to all numeric values. |
| propertyMap | Partial<Record<keyof T_Style, string>> | {} | Property-specific unit overwrites. |
| isUnitlessProperty | (property: string) => boolean | isUnitlessProperty | A function that determines whether a property should remain unitless. |
Returns
(Plugin) A plugin function that can be passed to the createRenderer function.
© 2024-present Robin Weser. All Rights Reserved.