dnanoCSS scans your DOM, parses utility classes, and injects real CSS at runtime — just like Tailwind, but built from scratch with Vanilla JS.
<!-- Write this in your HTML --> <div class="dn-flex dn-items-center dn-justify-center dn-bg-primary dn-text-white dn-p-24 dn-rounded-12"> dnanoCSS works! 🚀 </div> <!-- dnanoCSS auto-generates this --> .dn-bg-primary { background-color: #2563eb; } .dn-rounded-12 { border-radius: 12px; }
HOW IT WORKS
Engine boots after DOMContentLoaded fires.
Every element's classList is inspected for dn- prefixed classes.
Parser splits tokens, detects breakpoints, pseudo-states, and values.
Real CSS rules are built and injected into a <style> tag.
MutationObserver watches for new nodes automatically.
FEATURES
30+ named colors including semantic tokens like primary, danger, success. Use any as bg, text, or border.
Prefix any utility with sm:, md:, lg: for responsive styles. Generates real @media queries.
dn-hover-bg-primary, dn-focus-border-blue, dn-active-text-white — CSS pseudo-selectors built-in.
Generates real reusable CSS rules in a <style> tag — not inline styles. Each class processed only once.
Automatically detects dynamically added elements and applies utility styles without re-scanning the whole DOM.
Separated into engine, parser, utilities, and constants — extend any layer independently.
UTILITIES
LIVE DEMO
dn-bg-success dn-text-white
dn-bg-danger dn-rounded-10 dn-p-20
dn-bg-warning dn-text-black dn-p-20
Zero runtime overhead. CSS generated once, cached forever.
Any value, any property. No opinionated scale restrictions.
MutationObserver auto-handles dynamic content at runtime.
Click the button to inject a new element dynamically. dnanoCSS will style it instantly — no re-init needed.