Socket
Socket
Sign inDemoInstall

@unocss/transformer-compile-class

Package Overview
Dependencies
1
Maintainers
1
Versions
174
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @unocss/transformer-compile-class

Compile group of classes into one class


Version published
Weekly downloads
267K
decreased by-18.04%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

@unocss/transformer-compile-class

Compile group of classes into one class. Inspired by WindiCSS's compilation mode and #948 by @UltraCakeBakery.

Install

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

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:

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

Will be compiled to:

<div class="uno-qlmcrp">
  <div class="uno-0qw2gr"/>
</div>
.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 for details.

License

MIT License © 2021-PRESENT Anthony Fu

Keywords

FAQs

Last updated on 17 Nov 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc