Tailwind CSS
Tailwind is a **utility-first CSS framework**: you compose UI by combining small, predictable classes.
Install (Next.js + Tailwind)
bash
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -pConfigure content scanning:
js
// tailwind.config.js
module.exports = {
content: ["./src/**/*.{js,ts,jsx,tsx}", "./app/**/*.{js,ts,jsx,tsx}"],
theme: { extend: {} },
plugins: [],
}Add Tailwind layers:
css
/* src/styles/global.css */
@tailwind base;
@tailwind components;
@tailwind utilities;Build a “design token” layer (recommended)
Instead of sprinkling raw colors everywhere, define consistent tokens:
js
// tailwind.config.js
module.exports = {
theme: {
extend: {
colors: {
brand: {
50: "#eff6ff",
600: "#2563eb",
700: "#1d4ed8"
},
},
},
},
}Example: button component
tsx
export function PrimaryButton({ children }: { children: React.ReactNode }) {
return (
<button
className="inline-flex items-center gap-2 rounded-md bg-brand-600 px-4 py-2 text-sm font-semibold text-white shadow-sm
hover:bg-brand-700 focus:outline-none focus:ring-2 focus:ring-brand-600/40 active:translate-y-px"
>
{children}
</button>
);
}Preview: button (click to reveal code)
html Tailwind button
Real CSS with @layer (for reusable patterns)
css
@layer components {
.card {
@apply rounded-xl border border-white/10 bg-black/20 p-6 backdrop-blur;
}
.card-title {
@apply text-lg font-semibold tracking-tight;
}
}Common pitfalls (and fixes)
- **Huge class strings** → extract components, or use `@apply` for stable patterns.
- **Inconsistent spacing/colors** → enforce tokens and shared UI primitives.
- **CSS bloat** → ensure `content` paths are correct (purge works), avoid dynamic class names.
Production checklist
- Use a component library layer (your own) for buttons/cards/forms.
- Prefer semantic accessibility: focus rings, aria labels, keyboard flow.
- Document design tokens and keep them stable across pages.
Page changelog
Last updated
- 2026-01-18—Initial or baseline update for this page.
Related articles
Configuration
API Reference — Patterns and Generation
How to design, document, and (when possible) auto-generate reference docs from OpenAPI and source code.
Configuration
Ant Design — Enterprise UI Components for React
A mature enterprise component library. Learn how to install, theme, and use components with predictable layout and form patterns.
Configuration
MUI (Material UI) — Component Library with Theme Tokens
Build consistent UI fast with MUI themes, component overrides, and practical examples for React/Next.js.
Configuration
Styled Components — CSS-in-JS with Real CSS Snippets
Write component-scoped styles with full CSS power, theming, and patterns for scaling safely.
Configuration
Sass/SCSS — Structured CSS for Large Codebases
Use variables, mixins, and partials to keep CSS maintainable. Includes SCSS examples you can copy/paste.
Configuration
Scaling WordPress for High Traffic
Optimize WordPress performance using Redis Object Cache, Varnish, and database replication strategies.
Was this page helpful?