Skip to content

atlassian-labs/compiled

Folders and files

NameName
Last commit message
Last commit date

Latest commit

28bf423 · Apr 16, 2025
Feb 18, 2020
Apr 16, 2025
Feb 3, 2025
Sep 20, 2023
Jan 4, 2024
Feb 21, 2023
Jan 21, 2025
Mar 17, 2025
Apr 16, 2025
Oct 24, 2023
Sep 20, 2023
Mar 8, 2022
Jan 13, 2022
Apr 3, 2025
Dec 14, 2019
Dec 19, 2024
Dec 6, 2021
Aug 11, 2021
Sep 6, 2023
Oct 4, 2023
Oct 27, 2021
Jan 3, 2020
Apr 5, 2020
Jan 22, 2025
Dec 17, 2020
Mar 22, 2022
Dec 22, 2023
Mar 8, 2022
Mar 22, 2022
Mar 18, 2025
Jan 17, 2023
Mar 14, 2022
Dec 22, 2020
Mar 6, 2024
Mar 17, 2025

Repository files navigation

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