Installation
Get started with Headwind by installing it via your package manager or using pre-built binaries.
Package Managers
Install Headwind as a development dependency in your project:
bun add --dev headwind
# or
bun install --dev headwindnpm install --save-dev headwind
# or
npm i -D headwindpnpm add --save-dev headwind
# or
pnpm add -D headwindyarn add --dev headwindGlobal Installation
For global installation (to use the CLI anywhere):
bun add --global headwindnpm install --global headwind
# or
npm i -g headwindpnpm add --global headwindyarn global add headwindQuick Start
After installation, initialize a new Headwind project:
# Create configuration file
headwind init
# Build your CSS
headwind build
# Or use watch mode for development
headwind watchConfiguration
The headwind init command creates a basic headwind.config.ts file:
import type { HeadwindOptions } from 'headwind'
const config = {
content: ['./src/**/*.{html,js,ts,jsx,tsx}'],
output: './dist/headwind.css',
} satisfies HeadwindOptions
export default configCustomize this configuration to match your project structure. See the Configuration Guide for all available options.
Framework Integration
React / Next.js
# Install Headwind
bun add --dev headwind
# Create config
headwind initUpdate your headwind.config.ts:
import type { HeadwindOptions } from 'headwind'
const config = {
content: [
'./src/**/*.{js,ts,jsx,tsx}',
'./app/**/*.{js,ts,jsx,tsx}',
'./pages/**/*.{js,ts,jsx,tsx}',
'./components/**/*.{js,ts,jsx,tsx}',
],
output: './styles/headwind.css',
} satisfies HeadwindOptions
export default configImport the generated CSS in your app:
// app/layout.tsx or pages/_app.tsx
import './styles/headwind.css'Add build scripts to package.json:
{
"scripts": {
"dev": "headwind watch & next dev",
"build": "headwind build && next build"
}
}Vue / Nuxt
# Install Headwind
bun add --dev headwind
# Create config
headwind initUpdate your headwind.config.ts:
import type { HeadwindOptions } from 'headwind'
const config = {
content: [
'./components/**/*.{vue,js,ts}',
'./layouts/**/*.vue',
'./pages/**/*.vue',
'./app.vue',
],
output: './assets/css/headwind.css',
} satisfies HeadwindOptions
export default configImport in your app.vue or main layout:
<style>
@import './assets/css/headwind.css';
</style>Svelte / SvelteKit
# Install Headwind
bun add --dev headwind
# Create config
headwind initUpdate your headwind.config.ts:
import type { HeadwindOptions } from 'headwind'
const config = {
content: [
'./src/**/*.{html,js,svelte,ts}',
],
output: './static/headwind.css',
} satisfies HeadwindOptions
export default configImport in your root layout:
<!-- src/routes/+layout.svelte -->
<script>
import '/static/headwind.css'
</script>Astro
# Install Headwind
bun add --dev headwind
# Create config
headwind initUpdate your headwind.config.ts:
import type { HeadwindOptions } from 'headwind'
const config = {
content: [
'./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}',
],
output: './public/headwind.css',
} satisfies HeadwindOptions
export default configImport in your base layout:
---
// src/layouts/Layout.astro
import '/headwind.css'
---Plain HTML
# Install Headwind globally
bun add --global headwind
# Create config
headwind initUpdate your headwind.config.ts:
import type { HeadwindOptions } from 'headwind'
const config = {
content: ['./src/**/*.html'],
output: './dist/headwind.css',
} satisfies HeadwindOptions
export default configLink the CSS in your HTML:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="/dist/headwind.css">
</head>
<body>
<div class="flex items-center justify-center h-screen">
<h1 class="text-4xl font-bold text-blue-500">Hello Headwind!</h1>
</div>
</body>
</html>Binaries
Pre-built binaries are available for different platforms. Download the binary that matches your platform and architecture:
# Download the binary
curl -L https://github.com/stacksjs/headwind/releases/latest/download/headwind-darwin-arm64 -o headwind
# Make it executable
chmod +x headwind
# Move it to your PATH
sudo mv headwind /usr/local/bin/headwind# Download the binary
curl -L https://github.com/stacksjs/headwind/releases/latest/download/headwind-darwin-x64 -o headwind
# Make it executable
chmod +x headwind
# Move it to your PATH
sudo mv headwind /usr/local/bin/headwind# Download the binary
curl -L https://github.com/stacksjs/headwind/releases/latest/download/headwind-linux-arm64 -o headwind
# Make it executable
chmod +x headwind
# Move it to your PATH
sudo mv headwind /usr/local/bin/headwind# Download the binary
curl -L https://github.com/stacksjs/headwind/releases/latest/download/headwind-linux-x64 -o headwind
# Make it executable
chmod +x headwind
# Move it to your PATH
sudo mv headwind /usr/local/bin/headwind# Download the binary
curl -L https://github.com/stacksjs/headwind/releases/latest/download/headwind-windows-x64.exe -o headwind.exe
# Move it to your PATH (adjust the path as needed)
move headwind.exe C:\Windows\System32\headwind.exeTIP
You can also find Headwind binaries in GitHub releases.
Verify Installation
Verify that Headwind is installed correctly:
headwind --versionYou should see the installed version number.
Development Workflow
Watch Mode
During development, use watch mode to automatically rebuild CSS when files change:
headwind watchThis will:
- Watch all files matching your content patterns
- Automatically rebuild CSS on changes
- Show build statistics in the terminal
Build for Production
When building for production:
headwind build --minifyOr configure minification in your headwind.config.ts:
const config = {
content: ['./src/**/*.{html,js,ts,jsx,tsx}'],
output: './dist/headwind.css',
minify: process.env.NODE_ENV === 'production',
} satisfies HeadwindOptionsNext Steps
- Configuration Guide - Learn about all configuration options
- Usage Guide - Start using utility classes
- CLI Reference - Explore all CLI commands
- Compile Class Transformer - Optimize your HTML
Troubleshooting
Bun Not Found
If you get a "bun: command not found" error, install Bun:
curl -fsSL https://bun.sh/install | bashPermission Denied
If you get permission errors when installing globally:
# Use sudo on macOS/Linux
sudo bun add --global headwind
# Or install locally and use npx
bun add --dev headwind
bunx headwind buildTypeScript Errors
If you encounter TypeScript errors in your config file:
Ensure you have TypeScript installed:
bashbun add --dev typescriptUse the
satisfieskeyword for type checking:typescriptimport type { HeadwindOptions } from 'headwind' const config = { content: ['./src/**/*.tsx'], output: './dist/headwind.css', } satisfies HeadwindOptions
Build Errors
If the build fails:
Check that your content patterns are correct
Ensure the output directory exists or can be created
Run with
--verbosefor detailed error information:bashheadwind build --verbose