An object of CSS properties that don't accept values with units
92
Quality
Pending
Does it follow best practices?
Impact
92%
0.92xAverage score across 7 eval scenarios
Build a style value processor that formats numeric CSS values by adding appropriate units. The processor should handle both standard CSS properties and CSS custom properties (CSS variables).
Implement a function that processes CSS property-value pairs where the value is numeric. The function should:
--)px units to numeric values for properties that require units0 doesn't need units-- (hint: check the character code at position 1 for a hyphen, which has character code 45)flex and value 1, the function returns 1 @testopacity and value 0.8, the function returns 0.8 @testwidth and value 200, the function returns "200px" @test--my-custom-var and value 42, the function returns 42 @testmargin and value 0, the function returns 0 @test@generates
/**
* Processes a CSS property value by adding units when necessary.
*
* @param property - The CSS property name
* @param value - The numeric value
* @returns The formatted value (either as-is or with 'px' appended)
*/
export function processStyleValue(property: string, value: number): string | number;Provides a lookup object for CSS properties that don't require units.
Install with Tessl CLI
npx tessl i tessl/npm-emotion--unitless