Installation
Use coatx with zero bundler plugin or compose compiled StyleX maps directly.
Install coatx from npm:
bun add coatx
@stylexjs/stylex is the only runtime dependency. coatx has zero dependency on React, Ilha, or @ilha/ui-sdk.
Option 1: Zero-compiler setup
Import the pre-compiled stylesheet once at your app entry, apply a scoped theme, and spread recipe attributes onto any element:
import "coatx/styles.css";
import { button } from "coatx/button";
import { theme } from "coatx/themes.stylex";
export function Actions() {
return (
<div {...theme("dark")}>
<button type="button" {...button({ variant: "default" })}>
Save
</button>
<button type="button" {...button({ variant: "outline" })}>
Cancel
</button>
</div>
);
}
No Babel plugin, no Vite plugin, and no PostCSS configuration are required.
CSS import order
coatx/styles.css is fully layered (StyleX’s standard @layer priority1 … priority7), so any unlayered app CSS such as .my-btn{padding-inline:2rem} overrides it with no !important.
With Tailwind v4, import coatx into a named layer and pin the order once, so coatx sits above Tailwind’s preflight (base) and below utilities:
@layer theme, base, coatx, components, utilities;
@import "tailwindcss";
@import "coatx/styles.css" layer(coatx);
- Without the
@layerline, whichever stylesheet loads first declares its layers first: coatx-first lets Tailwind’s preflight reset button padding and backgrounds, Tailwind-first puts coatx above your utilities. - Apps that compile their own StyleX: skip
layer(coatx), compile withuseLayers: true, and see StyleX compiler mode — your rules share coatx’s priority layers. - No Tailwind?
import "coatx/styles.css"is all you need.
Option 2: StyleX-compiled composition
Apps that already compile StyleX with @stylexjs/babel-plugin can import coatx/tokens.stylex and any module’s *Styles map directly. coatx compiles its defineVars groups with canonical package paths so your stylex.createTheme(colors, ...) produces identical --x... CSS custom properties:
import * as stylex from "@stylexjs/stylex";
import { buttonStyles } from "coatx/button";
import { colors } from "coatx/tokens.stylex";
export const brandTheme = stylex.createTheme(colors, {
primary: "oklch(0.62 0.21 255)",
ring: "oklch(0.62 0.21 255)",
});
const custom = stylex.create({
square: { borderRadius: 0 },
});
export const squareButton = () =>
stylex.attrs(buttonStyles.base, buttonStyles.variantDefault, custom.square);
See StyleX compiler mode for Vite / Next.js setup.
Framework output (class vs className)
Every recipe and theme() emits { class, style }, which works natively in HTML, Ilha, Preact, Solid, Vue, Svelte, and Astro.
For React, convert with reactProps from coatx/react:
import "coatx/styles.css";
import { button } from "coatx/button";
import { reactProps } from "coatx/react";
import { theme } from "coatx/themes.stylex";
export function ReactActions() {
return (
<div
{...reactProps(
theme("dark", { colors: { primary: "oklch(0.62 0.21 255)" } })
)}
>
<button
type="button"
{...reactProps(
button({
class: "my-btn",
style: { marginTop: 8 },
variant: "outline",
})
)}
>
Save
</button>
</div>
);
}
In mixed-framework apps (for example, Astro with both Ilha and React islands), convert only the React side — Ilha and plain HTML keep the raw { class, style } output. See React and Other frameworks.
Subpath exports
Import from individual subpaths (coatx/button, coatx/dialog, coatx/themes, coatx/tokens.stylex, coatx/react) or from the root barrel (coatx). All published files under dist/ are strictly MIT licensed.