A lightweight, utility-first CSS engine built using JavaScript.
ChaiCSS allows developers to write expressive chai-* utility classes directly in HTML, which are dynamically converted into inline styles at runtime.
-
Utility-first CSS system
-
Config-driven architecture (easy to extend)
-
Supports core CSS domains:
- Typography
- Layout (Flexbox)
- Positioning
- Box Model
-
Multi-property utilities (e.g.,
px,py) -
Custom reusable components (buttons, cards, titles)
-
Automatic removal of processed classes
-
Lightweight and dependency-free
npm install @vickyxcodes/chai-windimport { initChaiCSS } from "@vickyxcodes/chai-wind";
document.addEventListener("DOMContentLoaded", () => {
initChaiCSS();
});<div class="chai-p-20 chai-bg-black chai-c-white chai-text-center">
Hello World
</div><div style="padding: 20px; background-color: black; color: white; text-align: center;">
Hello World
</div>chai-c-red
chai-bg-blackchai-p-10 → padding: 10px
chai-m-20 → margin: 20px
chai-px-10 → padding-left & right
chai-py-5 → padding-top & bottomchai-fs-20 → font-size: 20px
chai-fw-bold → font-weight: bold
chai-text-center → text-align: center
chai-lh-1.5 → line-heightchai-d-flex
chai-justify-center
chai-align-center
chai-gap-10chai-w-200
chai-h-100
chai-minw-100
chai-maxh-300chai-pos-absolute
chai-top-10
chai-left-20
chai-z-10chai-rounded-10
chai-border-2chai-overflow-hiddenchai-opacity-0.5
chai-shadow-0 4px 10px rgba(0,0,0,0.2)ChaiCSS also includes reusable UI-style utilities:
<h1 class="chai-title">Title</h1><p class="chai-description">Description text</p><button class="chai-btn-primary">Click Me</button><div class="chai-card">
<h2 class="chai-card-title">Card Title</h2>
<p>Content</p>
</div>- Traverses the DOM after page load
- Identifies all classes starting with
chai- - Parses class names into CSS properties and values
- Applies inline styles dynamically
- Removes processed classes from the DOM
src/
extract.js → DOM traversal and engine
parser.js → class parsing logic
map.js → utility configuration
utils.js → helper functionsThe system is designed with a clear separation of concerns:
- Parsing logic is independent of styling rules
- Styling rules are defined in a centralized configuration (
map.js) - DOM manipulation is handled separately in the engine
This makes the system scalable, maintainable, and easy to extend.
Inspired by utility-first frameworks like Tailwind CSS.
- Responsive utilities (e.g.,
md:,lg:) - State-based styles (hover, focus)
- Theme system
- Dark mode support
- Animation utilities
Vicky Gupta
ChaiCSS demonstrates how a scalable, utility-first CSS engine can be built from scratch using JavaScript, with a strong focus on modular architecture, extensibility, and real-world usability.