Menu

Introducing ONCSS: A Lightweight CSS-in-JS Library for Modern JavaScript Applications
📰

Introducing ONCSS: A Lightweight CSS-in-JS Library for Modern JavaScript Applications

DEV Community: javascript·Naxrul Ahmed·2 days ago
#BvgnPIhC
#devtojavascript#devto#dev#react#css
Long article (277 words) — no AI summary yet.
Reading 0:00
15s threshold

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 ,…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.