A semantic spacing system for Tailwind CSS v4, providing consistent layouts with block and tab units.
TW-Blocks is a Tailwind CSS v4 plugin that introduces a two-unit spacing system:
- Block units - Component sizes (inputs, buttons, toolbars) - Default: 32px
- Tab units - Padding and spacing - Default: 4px
- Ratio - 4 tabs = 1 block for predictable layouts
Add the TW-Blocks skill to your AI assistant (Cursor, Windsurf, etc.):
npx skills add vercel-labs/tw-blocksThis enables your AI to use TW-Blocks patterns automatically when building UIs.
pnpm add tw-blocksAdd to your CSS file:
@import "tailwindcss";
@import "tw-blocks";That's it! No configuration file needed.
<!-- Button: 32px height, 16px horizontal padding -->
<button class="h-block-1 px-tab-4 rounded-tab-2">
Click me
</button>
<!-- Input: 48px height -->
<input class="h-block-1.5 px-tab-4 rounded-tab-2" placeholder="Enter text">
<!-- Card: 24px padding, 12px border radius -->
<div class="p-tab-6 rounded-tab-3 bg-white shadow-md">
Card content
</div>
<!-- Sidebar: 256px width -->
<aside class="w-block-8 h-screen bg-gray-900">
Navigation
</aside>p-tab-{0, 0.5, 1, 1.5, 2, 2.5, 3, 4, 5, 6, 8, 10, 12, 16, 20, 24, 32}
p-block-{0, 0.5, 1, 1.5, 2, 2.5, 3, 4, 5, 6, 8, 10, 12, 16}
h-block-{0, 0.5, 1, 1.5, 2, 2.5, 3, 4, 5, 6, 8, 10, 12, 16}
w-block-{0, 0.5, 1, 1.5, 2, 2.5, 3, 4, 5, 6, 8, 10, 12, 16}
rounded-block-{0.5, 1}
rounded-tab-{1, 2, 3, 4}
Override the base sizes in your CSS:
@layer theme {
:root {
--spacing-block: 2.5rem; /* 40px instead of 32px */
--spacing-tab: 0.5rem; /* 8px instead of 4px */
}
}View production-ready examples:
- Dashboard - Enterprise dashboard with sidebar
- Design Tool - Design tool interface
- 3D Editor - 3D editor UI
Full documentation available in the docs app. Deploy to Vercel or run locally:
pnpm --filter docs devThis library is LLM-ready:
- llms.txt - AI crawler discovery
- Skill file - Complete guide at
SKILLS/tw-blocks/SKILL.md - Markdown API - Request with
Accept: text/markdownheader
Use the skill file with ChatGPT/Claude to generate UI components automatically.
tw-blocks/
├── packages/design-system/ # The tw-blocks plugin
├── apps/
│ ├── docs/ # Documentation site
│ └── ui-analyzer/ # Screenshot comparison tool
└── examples/ # Production examples
├── dashboard/
├── design-tool/
└── editor-3d/
# Install dependencies
pnpm install
# Start docs
pnpm --filter docs dev
# Start an example
pnpm --filter dashboard dev
# Build everything
pnpm build
# Run tests
pnpm test- Node.js 18+
- pnpm 8+
- Tailwind CSS v4+
- Tailwind CSS v4.2.0
- Next.js 14.2.35
- React 18.2.0
- TypeScript
- Turbo (monorepo build system)
MIT License - See LICENSE file for details.
This is a Vercel Labs project. Contributions welcome!
- Repository: vercel-labs/tw-blocks
- Documentation: Deploy docs to see full guide
- Examples: See
/examplesdirectory
Built by Vercel Labs