![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
jss-plugin-default-unit
Advanced tools
JSS plugin that adds default custom unit to numeric values where needed
The jss-plugin-default-unit npm package is a plugin for JSS (JavaScript Style Sheets) that automatically adds units to numeric values in style objects. This is particularly useful when working with CSS in JS, as it simplifies the process of defining styles by allowing developers to omit units for properties that require them, with the plugin automatically appending the appropriate unit based on the property.
Automatic unit appending
Automatically appends 'px' to numeric values for properties that typically require a pixel unit, while leaving unitless values as is for properties that do not require units.
{
container: {
width: 100, // becomes '100px' automatically
opacity: 0.5 // remains unitless as expected
}
}
Customizable unit mapping
Allows customization of the units appended to specific properties, enabling developers to specify alternative units like 'em' or 'rem' for properties like 'line-height' and 'font-size'.
jss.use(defaultUnit({
'line-height': 'em',
'font-size': 'rem'
}));
Styled-components is a library for styling React components using tagged template literals. It supports automatic unit appending in a similar way to jss-plugin-default-unit but is more focused on component-level styling with a CSS-in-JS approach.
Glamor is a CSS-in-JS library that allows for styling components with JavaScript. It offers similar functionality to jss-plugin-default-unit in terms of automatically appending units to styles defined in JavaScript, but it provides a different API and approach to styling.
JSS plugin that adds default custom unit to numeric values where needed
See our website jss-plugin-default-unit for more information.
Using npm:
npm install jss-plugin-default-unit
or using yarn:
yarn add jss-plugin-default-unit
FAQs
JSS plugin that adds default custom unit to numeric values where needed
The npm package jss-plugin-default-unit receives a total of 1,330,851 weekly downloads. As such, jss-plugin-default-unit popularity was classified as popular.
We found that jss-plugin-default-unit demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.