API reference
props
API reference for the `props` function
The css.props() function returns style object as hashed classes together while filtering out falsy values like undefined, false, or null. It is useful when conditionally combining styles.
The easiest way to follow the DRY principle is to make it a constant using defineConsts
.
Extract
The following is extracted at compile time and executed as ts code. (Vue and Svelte also execute as ts.)
Usage Patterns
Conditional styles
Only truthy values are preserved.
With ternary
Return value
Returns a single hashes string of space-separated styleObject, ignoring falsy inputs:
See Also
Good to know
Since falsy values are filtered out, you can use logical and, ternary
operators, etc. in argument expressions.
Nested ternary operators are not supported as this would require complex parsing.