styled-ppx integrates with ReScript through the standard npm ecosystem. The package ships a pre-built PPX binary alongside a small ReScript runtime library, so the only configuration required is two additions to yourDocumentation 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.
bsconfig.json.
Supported versions: ReScript v9 and v10. ReScript v11 support is currently in development — you can track progress in PR #482. For organisations that need prioritised compatibility for a specific version, sponsored development options are available.
Install the package
Install The package contains two entry points:
@davesnx/styled-ppx from npm. It works with both npm and yarn:@davesnx/styled-ppx/ppx— the PPX binary that transforms%styled.div(...),%cx(...), and%css(...)extensions at compile time.@davesnx/styled-ppx/rescript— the runtime library that exposes theCSSmodule used by the generated code.
Update bsconfig.json
Add the PPX binary under
"ppx-flags" and the runtime library under "bs-dependencies":@rescript/react is only required if you are using styled components (%styled.div, %styled.a, etc.). If you only use %cx or %css to generate classNames or rules, you can omit it.Write your first styled component
With the PPX configured, you can use all five extension points in any The
.res file. Here is a complete example showing a dynamic Link component and a %cx layout className used together in JSX:Link module is a fully typed React <a> component. The labelled argument ~color is exposed as a prop — it defaults to CSS.hex("4299E1") and is interpolated directly into the CSS string via $(color). The layout binding is a plain string holding a hashed className.Next steps
Once you have the basics running, explore the full API:- Styled components — all HTML tags, dynamic props, and
classNameextension - className with
%cx— generate classNames without creating a component - Keyframe animations — type-safe
@keyframesdefinitions - Global styles — resets and base styles with
%styled.global - CSS rule with
%css— single-rule values for composition with the Array API