Chai-Wind

1.0.9 · active · verified Tue Apr 21

chai-wind is a utility-first CSS-in-JS library designed exclusively for browser environments, focusing on a zero-dependency, no-build-step approach to styling. It allows developers to apply inline CSS styles to HTML elements by using `chai-` prefixed class names, such as `chai-bg-22c55e` or `chai-f-20`. The library operates by scanning the DOM for these special class names upon `DOMContentLoaded` and converting them directly into `element.style` properties. Currently at version `1.0.9`, it appears to be in an active development phase, though specific release cadence isn't detailed. Its primary differentiator is the complete eschewal of traditional CSS files, build tools, and bundlers, making it highly suitable for quick prototyping or projects where a minimal setup is paramount.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to include chai-wind directly in an HTML file using an ESM import and apply basic utility styles to elements.

<!DOCTYPE html>
<html>
<head>
  <title>Chai-Wind Quickstart</title>
  <style>
    body { font-family: sans-serif; margin: 2rem; }
  </style>
</head>
<body>
  <div class="chai-bg-22c55e chai-text-white chai-p-24 chai-rounded-8 chai-fw-700 chai-f-20">
    Hello, chai-wind 🍵
  </div>
  <p class="chai-text-orange chai-f-16 chai-dp-flex chai-mt-16">
    This paragraph has some inline styles applied via chai-wind classes.
  </p>

  <script type="module">
  import { applyChaiStyles } from "https://esm.sh/chai-winder@1.0.9";
  // For local development, you'd use: import { applyChaiStyles } from './node_modules/chai-wind/index.js';
  
  // Call applyChaiStyles to convert `chai-` prefixed classes to inline styles.
  // This function automatically waits for the DOMContentLoaded event.
  applyChaiStyles();
</script>

</body>
</html>

view raw JSON →