--- name: transformer-variant-group description: Shorthand for grouping utilities with common prefixes --- # Transformer Variant Group Enables shorthand syntax for grouping utilities with common prefixes. ## Installation ```ts import { defineConfig, transformerVariantGroup } from 'unocss' export default defineConfig({ transformers: [ transformerVariantGroup(), ], }) ``` ## Usage Group multiple utilities under one variant prefix using parentheses: ```html
``` ## Examples ### Hover States ```html ``` Expands to: `hover:bg-blue-600 hover:text-white hover:scale-105` ### Dark Mode ```html
Dark content
``` Expands to: `dark:bg-gray-800 dark:text-white` ### Responsive ```html
Responsive flex
``` Expands to: `md:flex md:items-center md:gap-4` ### Nested Groups ```html
Large screen hover
``` Expands to: `lg:hover:bg-blue-500 lg:hover:text-white` ### Multiple Prefixes ```html
Styled text
``` Expands to: `text-sm text-gray-600 font-medium font-mono` ## Key Points - Use parentheses `()` to group utilities - The prefix applies to all utilities inside the group - Can be combined with any variant (hover, dark, responsive, etc.) - Nesting is supported - Works in class attributes and other extraction sources