TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/davesnx/styled-ppx/llms.txt
Use this file to discover all available pages before exploring further.
%css / [%css] extension parses a single CSS declaration string at compile time and returns a Css.rule value. It is the smallest building block in styled-ppx — useful when you want to define one reusable rule and then compose it with others via the Array API or feed it into %cx and %styled.*.
Basic usage
Pass a singleproperty: value pair as a string literal. The extension returns a typed Css.rule value.
Features
- Single declarations only. You may write exactly one
property: valuepair — for examplecolor: blue. Multiple declarations (color: blue; background-color: red) and selector blocks (:hover { color: blue }) are not accepted. Use%cxor%styled.tagfor those cases. - The trailing semicolon is optional.
display: block;anddisplay: blockare identical. - No curly braces. Writing
{ display: block }is invalid inside%css.
What is NOT allowed
Invalid in %css | Use instead |
|---|---|
Multiple declarations: color: red; background: blue | %cx |
Selector blocks: &:hover { color: red; } | %cx |
At-rules: @media (...) { ... } | %cx |
Outer curly braces: { display: block } | Remove the braces |
Primary use case: building rule arrays
%css shines when combined with the Array API. You can define individual rules, mix in CSS.unsafe for unsupported properties, and assemble them into a class name or a styled component: