
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Write stylesheets in JS.
Works with any stack.
There are many ways of writing styles as JS (Free Style, restyle and babel-plugin-css-in-js â just to name a few). But none of them has the option to compile to a good old interoperable CSS stylesheet, or the new and shiny CSS module. I wanted an easy way to take advantage of JS goodness when writing stylesheets â a way compatible with any tech stack.
npm install [--save] css-in-js
const cssInJs = require('css-in-js');
const indigo = '#3F51B5';
⸠cssInJs({
'.my-button': {
'width': '50px',
'background-color': indigo,
},
'@media screen and (min-width: 80em)': {
'.my-button': {
'width': '100%',
},
},
});
â `
.my-button {
width: 50px;
background-color: #3F51B5;
}
@media screen and (min-width: 80em) {
.my-button {
width: 100%;
}
}
`
Any JS object is translated recursively to a CSS tree. To ensure two-way compatibility, we only support git.io/orthodox style objects.
When using fancy things which need a CSS fallback, you might want to set the same property more than once:
.drag-me {
cursor: pointer;
cursor: -webkit-grab;
cursor: grab;
}
To cover these cases, we allow passing an array of style objects:
⸠cssInJs({
'.drag-me': [{
cursor: 'pointer',
}, {
cursor: '-webkit-grab',
}, {
cursor: 'grab',
}],
});
â `
.drag-me {
cursor: pointer;
cursor: -webkit-grab;
cursor: grab;
}
`
css-in-js is heavily inspired by the great elm-css by Richard Feldman. The name is inspired by the disrupting React talk CSS in JS by Christopher Chedeau.
FAQs
Write stylesheets in JS. Works with any stack.
We found that css-in-js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.