一键导入
stacks-crosswind
// Use when styling components in a Stacks application — utility-first CSS classes, theming, responsive design, variants, custom rules, or CSS generation. Crosswind is the CSS utility engine powering Stacks' Headwind config.
// Use when styling components in a Stacks application — utility-first CSS classes, theming, responsive design, variants, custom rules, or CSS generation. Crosswind is the CSS utility engine powering Stacks' Headwind config.
| name | stacks-crosswind |
| description | Use when styling components in a Stacks application — utility-first CSS classes, theming, responsive design, variants, custom rules, or CSS generation. Crosswind is the CSS utility engine powering Stacks' Headwind config. |
| license | MIT |
| compatibility | Bun >= 1.3.0, TypeScript |
| allowed-tools | Read Edit Write Bash Grep Glob |
Crosswind (@cwcss/crosswind) is the utility-first CSS engine for Stacks — similar to Tailwind CSS but built for Bun.
node_modules/@cwcss/crosswind/config/ui.ts (Headwind options referencing Crosswind)storage/framework/defaults/styles/storage/framework/assets/headwind.cssimport { CSSGenerator } from '@cwcss/crosswind'
const generator = new CSSGenerator(config: CrosswindConfig)
generator.generate(className: string): void // Process a single class
generator.toCSS(includePreflight?, minify?): string // Output CSS
generator.reset(): void // Clear generated CSS
import { parseClass, expandBracketSyntax, extractClasses, extractAttributifyClasses } from '@cwcss/crosswind'
parseClass('hover:bg-blue-500'): ParsedClass
// { raw: 'hover:bg-blue-500', variants: ['hover'], utility: 'bg-blue-500', important: false, arbitrary: false }
extractClasses(htmlContent: string, options?): Set<string>
expandBracketSyntax('text-[#1a1a1a]', config?): string[]
extractAttributifyClasses(content, config?): Set<string>
import { Scanner } from '@cwcss/crosswind'
const scanner = new Scanner(patterns: string[], transformer?, extractOptions?)
await scanner.scan(): Promise<ScanResult>
await scanner.scanFile(filePath: string): Promise<Set<string>>
scanner.scanContent(content: string): Set<string>
import { build, writeCSS, buildAndWrite } from '@cwcss/crosswind'
const result = await build(config: CrosswindConfig): Promise<BuildResult>
await writeCSS(css: string, outputPath: string): Promise<void>
await buildAndWrite(config: CrosswindConfig): Promise<BuildResult>
interface BuildResult {
css: string
classes: Set<string>
duration: number
compiledClasses?: Map<string, { className: string, utilities: string[] }>
transformedFiles?: Map<string, string>
}
import { plugin } from '@cwcss/crosswind'
const bunPlugin = plugin(options?: CrosswindPluginOptions): BunPlugin
interface CrosswindConfig {
content: string[] // Glob patterns for source files
output: string // Output CSS file path
minify: boolean
watch: boolean
verbose?: boolean
theme: Theme
shortcuts: Record<string, string | string[]>
rules: CustomRule[]
variants: VariantConfig
safelist: string[] // Always include these classes
blocklist: string[] // Never include these classes
preflights: Preflight[]
presets: Preset[]
compileClass?: CompileClassConfig
attributify?: AttributifyConfig
bracketSyntax?: BracketSyntaxConfig
cssVariables?: boolean
}
interface Theme {
colors: Record<string, string | Record<string, string>>
spacing: Record<string, string>
fontSize: Record<string, [string, { lineHeight: string }]>
fontFamily: Record<string, string[]>
screens: Record<string, string>
borderRadius: Record<string, string>
boxShadow: Record<string, string>
extend?: Partial<Omit<Theme, 'extend'>>
}
responsive, hover, focus, active, disabled, dark, group, peer,
before, after, marker, first, last, odd, even, first-of-type,
last-of-type, visited, checked, focus-within, focus-visible,
placeholder, selection, file, required, valid, invalid, read-only,
autofill, open, closed, empty, enabled, only, target, indeterminate,
default, optional, print, rtl, ltr, motion-safe, motion-reduce,
contrast-more, contrast-less
interface ParsedClass {
raw: string // Original class string
variants: string[] // Applied variants (hover, focus, etc.)
utility: string // Core utility name
value?: string // Arbitrary value if present
important: boolean // Has ! prefix
arbitrary: boolean // Uses [] brackets
typeHint?: string // Type hint for arbitrary values
}
<div class="flex items-center justify-between p-4 bg-white rounded-lg shadow">
<h1 class="text-2xl font-bold text-gray-900">Title</h1>
<button class="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600">
Click me
</button>
</div>
<!-- Arbitrary values -->
<div class="text-[#1a1a1a] w-[calc(100%-2rem)] grid-cols-[1fr_2fr]">
<!-- Dark mode -->
<div class="bg-white dark:bg-gray-900 text-black dark:text-white">
<!-- Responsive -->
<div class="w-full md:w-1/2 lg:w-1/3">
config/ui.ts defines Headwind options which feed Crosswindstorage/framework/assets/headwind.css — not a typical dist/ directorytext-[#custom] for arbitrary values, same as Tailwind JIT[RegExp, (match) => Record<string, string>] tuplesUse when building, modifying, or debugging API endpoints in a Stacks application — defining routes, handling requests, API middleware, working with the API server, HTTP client (fetcher), API resources, or OpenAPI generation. Covers both @stacksjs/api utilities and the stacks-api server implementation.
Use when linting or formatting code in a Stacks project. CRITICAL - always use pickier, NEVER eslint directly. Run 'bunx --bun pickier .' to lint, 'bunx --bun pickier . --fix' to auto-fix. For unused variables, prefer eslint-disable-next-line comments over underscore prefix. Covers @stacksjs/lint and config/lint.ts.
Use when working with routing in a Stacks application — defining routes, HTTP methods, route groups, middleware, named routes, URL generation, request enhancement (Laravel-style input/query/file helpers), response helpers, error responses, route model binding, or rate limiting. Covers @stacksjs/router, routes/, and app/Routes.ts.
Use when defining or organizing route files in a Stacks application — creating route files in routes/, registering them in app/Routes.ts, using route prefixes and middleware groups, or the default API routes structure. For the router API itself (request helpers, response helpers, middleware classes), see stacks-router.
Use when working with UI in a Stacks application — components, composables, reactivity (refs/watch/computed), Craft native components, Headwind CSS, Crosswind utility framework, accessibility, or the STX templating engine. Covers @stacksjs/ui, @stacksjs/stx, and related UI tooling.