Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Configure and use UnoCSS atomic CSS engine with presets like Wind (Tailwind-compatible), Icons, and Attributify.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/transformer-variant-group.md
1---2name: transformer-variant-group3description: Shorthand for grouping utilities with common prefixes4---56# Transformer Variant Group78Enables shorthand syntax for grouping utilities with common prefixes.910## Installation1112```ts13import { defineConfig, transformerVariantGroup } from 'unocss'1415export default defineConfig({16transformers: [17transformerVariantGroup(),18],19})20```2122## Usage2324Group multiple utilities under one variant prefix using parentheses:2526```html27<!-- Before transformation -->28<div class="hover:(bg-gray-400 font-medium) font-(light mono)" />2930<!-- After transformation -->31<div class="hover:bg-gray-400 hover:font-medium font-light font-mono" />32```3334## Examples3536### Hover States3738```html39<button class="hover:(bg-blue-600 text-white scale-105)">40Hover me41</button>42```4344Expands to: `hover:bg-blue-600 hover:text-white hover:scale-105`4546### Dark Mode4748```html49<div class="dark:(bg-gray-800 text-white)">50Dark content51</div>52```5354Expands to: `dark:bg-gray-800 dark:text-white`5556### Responsive5758```html59<div class="md:(flex items-center gap-4)">60Responsive flex61</div>62```6364Expands to: `md:flex md:items-center md:gap-4`6566### Nested Groups6768```html69<div class="lg:hover:(bg-blue-500 text-white)">70Large screen hover71</div>72```7374Expands to: `lg:hover:bg-blue-500 lg:hover:text-white`7576### Multiple Prefixes7778```html79<div class="text-(sm gray-600) font-(medium mono)">80Styled text81</div>82```8384Expands to: `text-sm text-gray-600 font-medium font-mono`8586## Key Points8788- Use parentheses `()` to group utilities89- The prefix applies to all utilities inside the group90- Can be combined with any variant (hover, dark, responsive, etc.)91- Nesting is supported92- Works in class attributes and other extraction sources9394<!--95Source references:96- https://unocss.dev/transformers/variant-group97-->98