Skip to content
coatx
Esc
↑↓navigate↵open⌘Jpreview
On this page

Other frameworks

Use coatx in Solid, Vue, Svelte, Astro, and Preact — spread { class, style } directly.

Every coatx recipe returns plain { class, style } HTML attributes, so Solid, Vue, Svelte, Astro, and Preact need no adapter — spread the result onto any element.

Solid

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: "outline" })}>
        Save
      </button>
    </div>
  );
}

Stateful recipes take plain JS booleans (checked, open, pressed, …), which compose naturally with Solid signals:

const [on, setOn] = createSignal(false);
return (
  <button
    type="button"
    {...toggle({ pressed: on() })}
    onClick={() => setOn(!on())}
  >
    Bold
  </button>
);

Vue

Bind the recipe output with v-bind:

<script setup lang="ts">
import "coatx/styles.css";
import { button } from "coatx/button";
import { theme } from "coatx/themes.stylex";
</script>

<template>
  <div v-bind="theme('dark')">
    <button type="button" v-bind="button({ variant: 'outline' })">Save</button>
  </div>
</template>

Svelte

Spread the recipe output as component props:

<script lang="ts">
  import "coatx/styles.css";
  import { button } from "coatx/button";
  import { theme } from "coatx/themes.stylex";
</script>

<div {...theme("dark")}>
  <button type="button" {...button({ variant: "outline" })}>Save</button>
</div>

Astro

Astro templates accept class and style directly. Use .astro files for static markup, or hydrate an Ilha island for interactivity (see Ilha UI SDK & Astro):

---
import "coatx/styles.css";
import { button } from "coatx/button";
import { theme } from "coatx/themes.stylex";
---

<div {...theme("dark")}>
  <button type="button" {...button({ variant: "outline" })}>Save</button>
</div>

Preact

Preact accepts class natively, so recipes spread directly just like Solid:

import "coatx/styles.css";
import { button } from "coatx/button";

export function Actions() {
  return (
    <button type="button" {...button({ variant: "outline" })}>
      Save
    </button>
  );
}

React users: React needs className instead of class — use reactProps from coatx/react. See React.

Was this page helpful?