unitless
v1.0.1
Published
List of CSS properties which accept numbers but are not a unit of distance
Downloads
10
Maintainers
Readme
unitless
This package provides the list of unitless CSS properties (accepts a number but is not a distance).
The list of properties that match this criteria is from react-dom-bindings
's isUnitlessNumber.js
.
As of 1.0.0, the list is from 18.2.0 of react-dom-bindings
.
Usage
unitless
has two names exports: unitlessNumbers
and isUnitlessNumber
.
// unitlessNumbers is a Set
import { unitlessNumbers, isUnitlessNumber } from "unitless";
const property = "property";
const value = 1;
if (unitlessNumbers.has(property)) {
return value;
} else {
return value + "px";
}
// or more succinctly
return unitlessNumbers.has(property) ? value : value + "px";
// alternatively, using isUnitlessNumber
return isUnitlessNumber(property) ? value : value + "px";
Versioning
Any breaking changes to the API will constitute a major version.
Updates to the properties list will constitute a minor version.
Contributing
To install bun:
https://bun.sh/docs/installation
To install dependencies:
bun install
To build:
bun run build
License
Copyright © 2023 Alexander Liu, Meta Platforms, Inc. and affiliates
MIT License