Getting Started
Welcome to the Twigwind CSS Framework documentation. Twigwind is a utility-first CSS framework built with JavaScript for rapid prototyping and flexibility.
Why Twigwind?
Unlike tailwind or other CSS frameworks, Twigwind is designed to be highly customizable and extendable.
Twigwind achieves this through its unique CSS compiler that compiles classes into a single stylesheet.
π‘ Twigwind supports both runtime and build time unlike tailwindcss.
Installation
NPM Package
npm install twigwind
CDN package
Add Twigwind to your HTML:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/twigwind@latest/src/css.css">
<script src="https://cdn.jsdelivr.net/npm/twigwind@latest/src/css.min.js" type="module"></script>
Initialize Twigwind after DOM content loads:
<script>
document.addEventListener("DOMContentLoaded", () => {
document.querySelectorAll("[class]").forEach(el => Twigwind.twApply(el));
Twigwind.twInject();
});
</script>
β
Twigwind is now active β you can use its classes directly in your HTML.
Build System (Optional)
For optimized CSS generation:
node build.js
This will generate optimized CSS files in the dist/ directory.
Usage
Hereβs a quick example:
<h1 class="color-blue size-xl mb-20">Hello Twigwind</h1>
<div class="flex:row-center-center bg-green p-10">
<div class="bg-purple p-5 mr-10">Item 1</div>
<div class="bg-red p-5">Item 2</div>
</div>
Utilities
Twigwind includes utility classes for:
- Colors β e.g.
bg-blue,color-red - Spacing β e.g.
m-20,p-10 - Flex Layouts β e.g.
flex:row-center-center - Position β e.g.
absolute,top-10,z-20 - Animations β e.g.
animate-spin,animate-bounce - Gradients β e.g.
gradient-to-r-red-blue,gradient-45deg-purple-pink - Backgrounds β e.g.
clip-border,image-url-[URL] - Hover states β e.g.
hover:bg-purple
Examples
A section with hover effects:
<div class="flex:row-left-center">
<div class="bg-cyan hover:bg-purple size-md mr-10 p-10">Hover Me</div>
<div class="bg-lightBlue hover:bg-amber size-md p-10">Hover Me</div>
</div>
Framework Comparison
| Feature / Framework | W3.CSS | Tailwind | Bootstrap | Twigwind |
|---|---|---|---|---|
| Ease of Learning | βοΈ | β | β | βοΈ |
| Utility-First | β | β | β | β |
| Flexibility | βοΈ | β | βοΈ | β |
| Responsive | βοΈ | β | β | β |
| Prebuilt Components | βοΈ | β | β | β |
| Lightweight | β | βοΈ | β | β |
| Community | βοΈ | β | β | β |
| Integration | β | βοΈ | βοΈ | β |
| JS Integration | β | βοΈ | βοΈ | β |
| Prototyping | βοΈ | β | β | β |
β οΈ Note: Twigwind is still in development. Expect frequent updates.
β Deprecated: The
flex-center class has been replaced with flex:row-center-center.