百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
S

solid-styled

> 前端框架
开源

SolidJS 反应样式表

197 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

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 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScriptcsscss-in-jsscoped-csssolid-js

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类前端框架
定价开源

> 相关工具

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