# @unocss/transformer-compile-class

> Compile group of classes into one class

Latest version **66.10.5** (published 2026-09-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install @unocss/transformer-compile-class
pnpm add @unocss/transformer-compile-class
yarn add @unocss/transformer-compile-class
bun add @unocss/transformer-compile-class
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; popular repo.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 66.10.5 |
| Published | 2026-09-16 |
| First published | 2022-05-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 1 |
| Unpacked size | 7.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 18965 |
| Author | Anthony Fu <anthonyfu117@hotmail.com> |
| Maintainers | antfu, unocss-bot, zyyv |
| Keywords | unocss, unocss-transformer |

## Links

- npm: https://www.npmjs.com/package/@unocss/transformer-compile-class
- Repository: https://github.com/unocss/unocss
- Homepage: https://unocss.dev
- Issues: https://github.com/unocss/unocss/issues
- Funding: https://github.com/sponsors/antfu
- npm.io page: https://npm.io/package/@unocss/transformer-compile-class

## Dependencies (1)

- [@unocss/core](https://npm.io/package/@unocss/core.md) 66.10.5

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 66.10.5 (latest) — 2026-09-16
- 66.10.4 — 2026-09-15
- 66.10.3 — 2026-09-15
- 66.10.2 — 2026-09-11
- 66.10.1 — 2026-09-09
- 66.10.0 — 2026-09-04
- 66.9.2 — 2026-09-02
- 66.9.1 — 2026-09-01
- 66.8.1 — 2026-08-21
- 66.8.0 — 2026-08-19
- 66.8.0-beta.1 — 2026-08-19
- 66.7.5 — 2026-07-07
- 66.7.4 — 2026-06-29
- 66.7.4-beta.1 — 2026-06-29
- 66.7.3 — 2026-06-26
- … 268 more at https://npm.io/package/@unocss/transformer-compile-class/versions

## README

# @unocss/transformer-compile-class

<!-- @unocss-ignore -->

Compile group of classes into one class. Inspired by [WindiCSS's compilation mode](https://windicss.org/posts/modes.html#compilation-mode) and [#948](https://github.com/unocss/unocss/issues/948) by [@UltraCakeBakery](https://github.com/UltraCakeBakery).

## Install

```bash
npm i -D @unocss/transformer-compile-class
```

```ts
import transformerCompileClass from '@unocss/transformer-compile-class'
// uno.config.ts
import { defineConfig } from 'unocss'

export default defineConfig({
  // ...
  transformers: [
    transformerCompileClass(),
  ],
})
```

## Usage

At the begin of your class strings, **add `:uno:` at the begin of the strings** to mark them for compilation. For example:

```html
<div class=":uno: text-center sm:text-left">
  <div class=":uno: text-sm font-bold hover:text-red" />
</div>
```

Will be compiled to:

```html
<div class="uno-qlmcrp">
  <div class="uno-0qw2gr" />
</div>
```

```css
.uno-qlmcrp {
  text-align: center;
}
.uno-0qw2gr {
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 700;
}
.uno-0qw2gr:hover {
  --un-text-opacity: 1;
  color: rgb(248 113 113 / var(--un-text-opacity));
}
@media (min-width: 640px) {
  .uno-qlmcrp {
    text-align: left;
  }
}
```

## Options

You can config the trigger string and prefix for compile class with the options. Refers to [the types](https://github.com/unocss/unocss/blob/main/packages-presets/transformer-compile-class/src/index.ts#L4) for details.

## License

MIT License &copy; 2021-PRESENT [Anthony Fu](https://github.com/antfu)

---
_Source: https://npm.io/package/@unocss/transformer-compile-class · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
