I've been working on ONCSS , a CSS-in-JS library designed to make styling modern web applications simple, flexible, and developer-friendly.
Instead of writing separate CSS files for every component, ONCSS lets you define styles directly in JavaScript using a familiar object-based API.
Why ONCSS?
ONCSS provides a css() function that generates and injects CSS dynamically.
Here's a quick example:
import css from "oncss" ;
const button = css ( { backgroundColor : "#2563eb" , color : "#fff" , padding : "10px 20px" , borderRadius : "8px" ,
"&:hover" : { backgroundColor : "#1d4ed8" , } ,
"@media (min-width: 768px)" : { padding : "14px 28px" , } , } ) ;
function Button ( ) { return < button className = { button } > Click me </ button > ; }
Enter fullscreen mode
Exit fullscreen mode
Features
Object-based CSS styling
Nested selectors and pseudo-classes
Responsive media queries
Custom breakpoints
Dynamic keyframes and animations
Global styles
CSS at-rules: @media , @container , @layer ,…