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

compiled

> 前端框架
开源

一个熟悉且性能出色的编译时 CSS-in-JS 库,用于 React。

2.1K stars0 点赞0 次浏览
访问官网GitHub

工具介绍

一个熟悉且性能出色的编译时 CSS-in-JS 库,用于 React。

Compiled

A familiar and performant compile time CSS-in-JS library for React. Get started now ➚

Usage

javascript
import { styled, ClassNames } from '@compiled/react';

// Tie styles to an element
<div css={{ color: 'purple' }} />

// Create a component that ties styles to an element
const StyledButton = styled.button`
  color: ${(props) => props.color};
`;

// Use a component where styles are not necessarily tied to an element
<ClassNames>
  {({ css }) => children({ className: css({ fontSize: 12 }) })}
</ClassNames>

Extract styles

Turn on extraction and all components styled in your app and sourced through NPM will have their runtime stripped and styles extracted to an atomic style sheet.

diff
-import { CC, CS } from '@compiled/react/runtime';
-
-const _2 = '._syaz1q9v{color: hotpink}';
-const _ = '._1wybfyhu{font-size: 48px}';
-
export const LargeHotPinkText = () => (
-  <CC>
-   <CS>{[_, _2]}</CS>
    <span className="_syaz1q9v _1wybfyhu">Hello world</span>
-  </CC>
);
css
._1wybfyhu {
  font-size: 48px;
}
._syaz1q9v {
  color: hotpink;
}

See CSS extraction for more information.

Installation

Install the React package.

bash
npm install @compiled/react

Then configure your bundler of choice or use Babel directly.

Webpack

Install the Webpack loader.

bash
npm install @compiled/webpack-loader --save-dev

See installation for more information.

Parcel

Install the Parcel v2 configuration.

bash
npm install @compiled/parcel-config --save-dev

Extend from the .parcelrc configuration:

json
{
  "extends": ["...", "@compiled/parcel-config"]
}

See installation for more information.

Babel

Install the Babel plugin.

bash
npm install @compiled/babel-plugin --save-dev

See installation for more information.

Contributions

Contributions are welcomed! Please see CONTRIBUTING.md to get started.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

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

> 标签

TypeScriptbabelcsscss-in-jsparcel

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

> 工具信息

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

> 相关工具

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