Usage
Import the runtime once, then write chai-* classes directly on your HTML elements. No config, no build step — styles are injected automatically when the DOM is ready.
Install via npm
Install the package from npm using your preferred package manager.
npm install chaiwind-css
# or
pnpm add chaiwind-css
# or
yarn add chaiwind-cssThen import it once at your app entry point:
import "chaiwind-css";Place the import in your entry file — for example main.jsx, main.ts, or app/layout.tsx — so styles are available before your components render.
Or use the CDN
No bundler? Drop a single script tag into your HTML file.
<script
type="module"
src="https://cdn.jsdelivr.net/npm/chaiwind-css/src/index.js"
></script>Add the tag inside <head> or just before </body>. Chaiwind will auto-run once the DOM is ready.
Apply utility classes
Start writing chai-* classes on any HTML element.
<!-- Flex layout with spacing and border -->
<div class="chai-flex chai-items-center chai-gap-4 chai-p-4 chai-rounded-lg chai-border">
<img class="chai-h-10 chai-w-10 chai-rounded-full" src="avatar.jpg" />
<div class="chai-flex chai-flex-col chai-gap-1">
<p class="chai-text-base chai-font-semibold">Gopal Choudhary</p>
<p class="chai-text-sm chai-text-gray">Software Developer</p>
</div>
</div>
<!-- Grid layout -->
<div class="chai-grid chai-grid-cols-3 chai-gap-4 chai-p-4">
<div class="chai-bg-red chai-rounded-lg chai-p-4" />
<div class="chai-bg-green chai-rounded-lg chai-p-4" />
<div class="chai-bg-blue chai-rounded-lg chai-p-4" />
</div>
<!-- Typography -->
<h1 class="chai-text-4xl chai-font-bold chai-tracking-tight">
Hello, Chaiwind!
</h1>
<p class="chai-text-lg chai-text-gray chai-leading-normal">
Supporting description text.
</p>How it works
01
Scans the DOM
Finds every element with a class attribute on DOMContentLoaded.
02
Matches classes
Looks up each chai- class in the utility dictionary via exact O(1) lookup.
03
Injects styles
Applies matched styles using setProperty() — no cssText conflicts.
Available utility groups
- Spacingchai-p-*, chai-m-*, chai-px-*, chai-py-*, chai-mt-*, chai-mx-auto
- Typographychai-text-*, chai-font-*, chai-leading-*, chai-tracking-*
- Colorschai-bg-*, chai-text-{color}
- Layoutchai-flex, chai-grid, chai-grid-cols-*, chai-items-*, chai-justify-*
- Sizingchai-w-*, chai-h-*, chai-min-w-*, chai-max-w-*
- Positionchai-relative, chai-absolute, chai-fixed, chai-sticky, chai-z-*
- Borderschai-border-*, chai-rounded-*
- Shadowschai-shadow-{sm|md|lg|xl|2xl}
- Transitionschai-transition, chai-duration-*, chai-ease-*
- Animationschai-animate-{spin|ping|bounce|pulse}
- Opacitychai-opacity-{0|25|50|75|100}
- Overflow & Cursorchai-overflow-*, chai-cursor-*