React
Use coatx in React via reactProps, plus Base UI, Radix, and React Aria examples.
React uses className and object style, while coatx recipes return framework-neutral { class, style }. 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 Actions() {
return (
<div {...reactProps(theme("dark"))}>
<button type="button" {...reactProps(button({ variant: "outline" }))}>
Save
</button>
</div>
);
}
reactProps maps class to className and parses the style string into a camelCase object (--custom-props are kept verbatim). Extra class/style inputs merge the same way as everywhere else:
<button
type="button"
{...reactProps(button({ class: "my-btn", variant: "outline" }))}
/>
Base UI
Base UI parts render plain HTML elements, so spread converted props directly. Stateful styles also respond to Base UI’s data-* attributes (see Headless UI & state), so checked/pressed/selected states work with no extra wiring:
import { Checkbox } from "@base-ui/react/checkbox";
import { checkbox, checkboxIndicator } from "coatx/checkbox";
import { reactProps } from "coatx/react";
export function Agree() {
return (
<Checkbox.Root {...reactProps(checkbox())}>
<Checkbox.Indicator {...reactProps(checkboxIndicator())} />
</Checkbox.Root>
);
}
Radix
Radix Primitives communicate state through data-state / data-highlighted attributes, which coatx CSS already matches. Render the primitive, spread the recipe, done:
import * as Select from "@radix-ui/react-select";
import { reactProps } from "coatx/react";
import { selectContent, selectItem, selectTrigger } from "coatx/select";
export function Picker() {
return (
<Select.Root>
<Select.Trigger {...reactProps(selectTrigger())} />
<Select.Content {...reactProps(selectContent())}>
<Select.Item value="apple" {...reactProps(selectItem())}>
<Select.ItemText>Apple</Select.ItemText>
</Select.Item>
</Select.Content>
</Select.Root>
);
}
Open/checked/highlighted visuals follow data-state automatically — no render prop needed.
React Aria
React Aria Components uses the render-prop pattern (className as a function of state). Pass the coatx recipe through the JS props for state-dependent parts:
import { Checkbox } from "react-aria-components";
import { checkbox, checkboxIndicator } from "coatx/checkbox";
import { reactProps } from "coatx/react";
export function Agree() {
return (
<Checkbox>
{({ isSelected, isIndeterminate, isInvalid }) => (
<span
{...reactProps(
checkbox({
checked: isSelected,
indeterminate: isIndeterminate,
invalid: isInvalid,
})
)}
>
<span {...reactProps(checkboxIndicator())} />
</span>
)}
</Checkbox>
);
}
The same pattern applies to any render-prop library: read state from the render prop, feed it to the recipe as plain JS booleans.