Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
S

solid-styled

> 前端框架
Open source

Reactive stylesheets for SolidJS

197 stars0 likes1 views
WebsiteGitHub

About

Reactive stylesheets for SolidJS

solid-styled

Reactive stylesheets for SolidJS

Install

bash
npm i solid-styled
npm i -D postcss
bash
yarn add solid-styled
yarn add -D postcss
bash
pnpm add solid-styled
pnpm add -D postcss

Features

  • Render stylesheets only once

  • Fine-grained reactive CSS properties

  • Scoped stylesheets

  • :global selector

  • @global at-rule

  • SSR

  • Near zero-runtime

  • `

     {
      setColor((c) => (c === 'red' ? 'blue' : 'red'));
    }}>
      Current color: {color()}

    ); }


You can also use `` for declaring global styles.

The main motivation for writing an alternative way of declaring styles with `` is to facilitate the migration from `solid-styled-jsx` to `solid-styled`. Possibly, some developers may as well use `` because of their familiarity with adding the styles inside the JSX.

## SSR

### ``

For SSR, you can pass an array to the `styles` prop of ``. This array collects all of the "critical" (initial render) stylesheets, that which you can render as a string with `renderSheets`.

```js
import { renderSheets } from 'solid-styled';

const styles = [];

renderToString(() => (
  
    
  
));

// Render sheets
// You can use the resulting sheet by inserting
// it into an HTML template.
const styles = renderSheets(styles);

Alternatively, for automatic sheet rendering (assuming that you are server-rendering the entire document), you can do

javascript
renderToString(() => (
  
    
  
));

CSS Processing

solid-styled uses LightningCSS to preprocess CSS templates as well as apply CSS scoping and transformations. By default, CSS Nesting and Custom Media Queries are enabled by default.

Limitations

  • Scoping css can only be called directly on components. This is so that the Babel plugin can find and transform the JSX of the component. Global css (i.e. :global or @global) can be used inside other functions i.e. hooks, utilities.
  • Dynamic styles are only limited to CSS properties.

Sponsors

License

MIT © lxsmnsyc

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

TypeScriptcsscss-in-jsscoped-csssolid-js

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category前端框架
PricingOpen source

> Related tools

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架