Reactive stylesheets for SolidJS
npm i solid-styled
npm i -D postcssyarn add solid-styled
yarn add -D postcsspnpm add solid-styled
pnpm add -D postcssRender 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
renderToString(() => (
));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.
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.MIT © lxsmnsyc
No open issues yet, or sync has not completed.