Core utilities for tailwind-expand
npm install @tailwind-expand/coreCore utilities for tailwind-expand. This is an internal package used by other @tailwind-expand packages.
``bash`
pnpm add @tailwind-expand/core
Parses a CSS file and extracts all @expand block aliases.
`ts
import { extract } from '@tailwind-expand/core'
const result = extract('./globals.css')
// { aliases: { Button: 'text-sm inline-flex', ButtonMd: 'h-10 px-4' }, hash: '...' }
`
Parses CSS content directly.
`ts
import { extractFromCSS } from '@tailwind-expand/core'
const aliases = extractFromCSS(
@expand Button {
@apply text-sm;
})`
// { Button: 'text-sm' }
Resolves alias references (e.g., when Button contains TypographyCaption).
`ts
import { expand } from '@tailwind-expand/core'
const expanded = expand({
TypographyCaption: 'text-xs font-bold',
Button: 'TypographyCaption inline-flex',
})
// { TypographyCaption: 'text-xs font-bold', Button: 'text-xs font-bold inline-flex' }
`
Scans source files for variant-prefixed aliases (e.g., lg:Button`) and collects them.
Collects variant-prefixed aliases from a single code string.
MIT