CSX (CSS eXpressions) is a utility library designed to simplify the creation of strongly typed CSS values and functions within TypeScript environments, primarily serving as a companion to the TypeStyle library. It offers a comprehensive set of helpers for common CSS properties and units, such as `color`, `rgb`, `hsl`, `px`, `em`, `percent`, as well as shorthand properties like `margin` and `padding`. The current stable version, 10.0.2, reflects ongoing development with a recent focus on aligning its output more closely with the CSS Object Model (CSSOM) for improved consistency and testability across different browsers and testing setups. This includes changes to color function spacing and the addition of optional alpha parameters for `rgb()` and `hsl()`. CSX maintains an active release cadence, delivering continuous enhancements and bug fixes. Its core differentiator lies in providing a robust, type-safe API for dynamic CSS value generation, significantly reducing runtime errors and improving code maintainability compared to raw string concatenation or less-typed approaches.
npm install csxVerified import paths — ran on the pinned version, not inferred.
Demonstrates defining various CSS values and shorthands using CSX helpers like colors, units, margins, and then integrating them into a TypeStyle stylesheet.
Update any snapshot tests or assertions that directly compare the string output of CSX color functions. No code change is typically required for runtime behavior unless specific string comparisons are in place.
Verify `background-size` usage. If you were implicitly relying on incorrect output, ensure your code now explicitly passes position and size, e.g., `backgroundSize('center', '50%')` to get `'center / 50%'`.Ensure that when providing a `size` argument to `backgroundSize()`, a valid `position` argument (even if 'initial' or '0 0') is also provided to satisfy the type definition.
Ensure that CSX is used alongside TypeStyle, as it's designed to complement its functionality. If you need vendor prefixing control, manage it via TypeStyle's configuration.
This is an intended breaking change in output formatting. Adjust any tests or code that performs exact string comparisons on color function outputs to reflect the new spaced format. No functional code change is needed.
Always use the appropriate CSX helper functions for units and values, e.g., `px(10)` instead of `'10px'`, or `percent(50)` instead of `'50%'`. Ensure types match the function signatures.
Update your import statements to use ES module syntax: `import { color } from 'csx';`. Ensure your project's `tsconfig.json` (if applicable) and build setup are configured for ES modules (e.g., `"module": "esnext"` or `"nodenext"`).No dependency data recorded yet.