Compiled CSS-in-JS

一个适用于 React 的常见的 、且性能良好的编译时 CSS-in-JS 库。「A familiar and performant compile time CSS-in-JS library for React.」

Github星跟蹤圖

Compiled

A familiar and performant compile time CSS-in-JS library for React.

Apache 2.0
@compiled/react
PRs welcome

Get started now ➚

Usage

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.

-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>
);
._1wybfyhu {
  font-size: 48px;
}
._syaz1q9v {
  color: hotpink;
}

See CSS extraction for more information.

Installation

Install the React package.

npm install @compiled/react

Then configure your bundler of choice or use Babel directly.

Webpack

Install the Webpack loader.

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

See installation for more information.

Parcel

Install the Parcel v2 configuration.

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

Extend from the .parcelrc configuration:

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

See installation for more information.

Babel

Install the Babel plugin.

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

See installation for more information.

Contributions

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

Atlassian

主要指標

概覽
名稱與所有者atlassian-labs/compiled
主編程語言TypeScript
編程語言TypeScript (語言數: 6)
平台
許可證Apache License 2.0
所有者活动
創建於2019-12-13 10:03:48
推送於2025-05-06 03:26:38
最后一次提交2025-04-16 11:26:53
發布數510
最新版本名稱@compiled/react@0.18.4 (發布於 2025-04-16 02:00:24)
第一版名稱v0.0.1 (發布於 2020-01-03 23:30:32)
用户参与
星數2k
關注者數11
派生數69
提交數1.6k
已啟用問題?
問題數444
打開的問題數115
拉請求數1218
打開的拉請求數27
關閉的拉請求數124
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?