JS 中的 CSS

JS 库中的 CSS

¥CSS in JS libraries

你可以使用 CSS-in-JS 库,例如 Styled Components 和 Emotion。有些需要 "双重渲染" 在服务器渲染期间从组件树中提取样式。

¥You can use CSS-in-JS libraries like Styled Components and Emotion. Some of them require a "double render" to extract the styles from the component tree during the server render.

由于每个库的集成方式不同,请查看我们的 示例代码库 来了解如何使用一些最流行的 CSS-in-JS 库。如果你有一个运行良好但尚未介绍的库,请 贡献示例

¥Since each library is integrated differently, check out our examples repo to see how to use some of the most popular CSS-in-JS libraries. If you've got a library working well that hasn't been covered, please contribute an example!

不建议在 Remix 中使用大多数 CSS-in-JS 方法,因为它们要求你的应用在你知道样式之前完全渲染。这是一个性能问题,并且会阻止像 defer 这样的流式传输功能。

Remix v2.17 中文网 - 粤ICP备13048890号