An atomic CSS-in-JS library with zero runtime overhead and CSS deduplication.
This project is currently available to sponsors until I reach 50 sponsors. After that, I will make the project publicly available.
Before transpiling:
// your JavaScript file
import { getAtomicClasses } from 'prtcls'
const btnRedClasses = getAtomicClasses(`
padding: 10px;
background: red;
`)
const btnBlueClasses = getAtomicClasses(`
padding: 10px;
background: blue;
`)
console.log(btnRedClasses, btnBlueClasses)
/* prtcls.css */
After transpiling:
// your JavaScript file
const btnRedClasses = 'p_10px bg_red'
const btnBlueClasses = 'p_10px bg_blue'
console.log(btnRedClasses, btnBlueClasses)
/* prtcls.css */
.p_10px {
padding: 10px;
}
.bg_red {
background: red;
}
.bg_blue {
background: blue;
}
The library accepts any CSS as a JavaScript style object or a string. At build time the library gets removed and those styles get turned into a string of corresponding classes based on their media query, pseudo selector, property, and value.
** Callback functions are used to inject config options, but cannot depend on any runtime variables (yet).**