JSX Props
CSSX extends JSX with custom props for styling.
styleName
Apply class-based styles to an element. Works like className but with scoped, processed styles.
Syntax Options:
Array Pattern (Recommended)
Use arrays with an object at the end for modifiers:
The pattern:
- Static base classes first (
'card') - Dynamic variant strings next (
variant— could be'featured','simple', etc.) - Boolean modifiers in an object at the end (
{ highlighted, compact })
Tip: Name variables to match class names for clean shorthand: { active } instead of { active: isActive }.
Dynamic Styles
For truly dynamic values, combine styleName with the style prop:
part
Expose an element for external styling via :part().
The Babel transform automatically injects the part style props — no manual prop spreading needed.
Parent components can then style these parts:
How Parts Work
- Child component marks elements with
part="name" - Parent uses
:part(name)selector to target those elements - Babel transforms both sides to connect them automatically
See the Component Parts guide for detailed examples.
matcher
The internal function that matches styleName values against compiled styles. Advanced use only.
Signature:
Parameters:
styleName- Space-separated class names (supports classnames-like syntax)fileStyles- Styles from the imported CSS fileglobalStyles- Module-levelstylstyleslocalStyles- Function-levelstylstylesinlineStyleProps- Inline style overrides
Returns: An object with style props, including style and any {part}Style props.