Maple

Style pages with utility classes - no build step, no configuration

A runtime CSS engine that generates atomic styles from the utility classes it finds on the page. Instead of shipping a compiled stylesheet, it ships a small script that watches the DOM and builds the CSS as elements appear. Add one script tag to any page and start styling.

What we love ❤️

  • Open source under a permissive MIT-style license
  • Works anywhere you can add a script tag - any framework, any backend, or plain HTML
  • One ~14kb file no matter how large the project grows
  • Styles are generated only for classes that actually appear, so there is no unused CSS
  • No build step, no config file, no dependencies to install
  • Server-rendered and static HTML need no special treatment
  • Playground to try the syntax before committing to it

Worth noting 💡

  • Requires JavaScript - pages render unstyled if it is disabled
  • Must be loaded as a blocking script in the head, or you may get a flash of unstyled content
  • Generation work scales with the number of unique classes on the page
  • Keyframes, font-face declarations and global resets are still better written as plain CSS

Maple takes the opposite path from the usual CSS toolchain: rather than scanning source files and compiling a stylesheet ahead of time, it waits until a class shows up on the page and styles it then. The trade is a runtime dependency in exchange for having nothing to configure and nothing to purge. Worth a look if your styling setup has grown more complicated than the styling itself.