setup-tailwind-typescript
Configure Tailwind CSS with TypeScript in a Next.js or React project. Covers installation, configuration, custom theme extensions, component patterns, and type-safe styling utilities. Use to add Tailwind CSS to an existing TypeScript project, customize the Tailwind theme for a project's design system, set up type-safe component styling patterns, or configure Tailwind plugins and extensions.
Best use case
setup-tailwind-typescript is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Configure Tailwind CSS with TypeScript in a Next.js or React project. Covers installation, configuration, custom theme extensions, component patterns, and type-safe styling utilities. Use to add Tailwind CSS to an existing TypeScript project, customize the Tailwind theme for a project's design system, set up type-safe component styling patterns, or configure Tailwind plugins and extensions.
Teams using setup-tailwind-typescript should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/setup-tailwind-typescript/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How setup-tailwind-typescript Compares
| Feature / Agent | setup-tailwind-typescript | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Configure Tailwind CSS with TypeScript in a Next.js or React project. Covers installation, configuration, custom theme extensions, component patterns, and type-safe styling utilities. Use to add Tailwind CSS to an existing TypeScript project, customize the Tailwind theme for a project's design system, set up type-safe component styling patterns, or configure Tailwind plugins and extensions.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Set Up Tailwind CSS with TypeScript
Configure Tailwind CSS in a TypeScript project with custom theme, utilities, and type-safe patterns.
## When to Use
- Adding Tailwind CSS to an existing TypeScript project
- Customizing Tailwind theme for a project's design system
- Setting up type-safe component styling patterns
- Configuring Tailwind plugins and extensions
## Inputs
- **Required**: TypeScript project (Next.js, Vite, or standalone React)
- **Optional**: Design system tokens (colors, spacing, fonts)
- **Optional**: Tailwind plugins to include
## Procedure
### Step 1: Install Tailwind CSS
```bash
npm install -D tailwindcss @tailwindcss/postcss postcss
```
For Next.js (if not already included):
```bash
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
```
**Got:** `tailwindcss`, `postcss`, and `autoprefixer` installed as dev dependencies. For Next.js, `tailwind.config.ts` and `postcss.config.js` are generated by `npx tailwindcss init -p`.
**If fail:** If `npx tailwindcss init` fails, install Tailwind first with `npm install -D tailwindcss` and retry. In a monorepo, run the command from the app's root directory, not the workspace root.
### Step 2: Configure tailwind.config.ts
```typescript
import type { Config } from "tailwindcss";
const config: Config = {
content: [
"./src/pages/**/*.{js,ts,jsx,tsx,mdx}",
"./src/components/**/*.{js,ts,jsx,tsx,mdx}",
"./src/app/**/*.{js,ts,jsx,tsx,mdx}",
],
theme: {
extend: {
colors: {
primary: {
50: "#eff6ff",
100: "#dbeafe",
500: "#3b82f6",
600: "#2563eb",
700: "#1d4ed8",
900: "#1e3a5f",
},
secondary: {
500: "#6366f1",
600: "#4f46e5",
},
},
fontFamily: {
sans: ["Inter", "system-ui", "sans-serif"],
mono: ["JetBrains Mono", "monospace"],
},
spacing: {
"18": "4.5rem",
"88": "22rem",
},
},
},
plugins: [],
};
export default config;
```
**Got:** `tailwind.config.ts` has a `content` array matching the project's file locations, custom colors and fonts under `theme.extend`, and proper TypeScript typing with the `Config` import.
**If fail:** If custom classes do not render, verify the `content` paths match your actual directory structure. Paths are glob patterns relative to the project root. Missing paths mean Tailwind will not scan those files for class usage.
### Step 3: Set Up Global Styles
Edit `src/app/globals.css`:
```css
@tailwind base;
@tailwind components;
@tailwind utilities;
@layer base {
html {
@apply antialiased;
}
body {
@apply bg-white text-gray-900 dark:bg-gray-950 dark:text-gray-100;
}
}
@layer components {
.btn-primary {
@apply bg-primary-600 text-white px-4 py-2 rounded-lg
hover:bg-primary-700 focus:outline-none focus:ring-2
focus:ring-primary-500 focus:ring-offset-2
transition-colors duration-200;
}
}
```
**Got:** `globals.css` contains the three Tailwind directives (`@tailwind base`, `@tailwind components`, `@tailwind utilities`) plus any custom base and component layer styles. The file is imported in the root layout.
**If fail:** If styles are not applied, verify `globals.css` is imported in `layout.tsx` (or `_app.tsx` for Pages Router). Check that the Tailwind directives are present and not commented out.
### Step 4: Create Type-Safe Utility Helpers
Create `src/lib/cn.ts`:
```typescript
import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
```
Install dependencies:
```bash
npm install clsx tailwind-merge
```
Usage in components:
```tsx
import { cn } from "@/lib/cn";
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
variant?: "primary" | "secondary" | "outline";
}
export function Button({ className, variant = "primary", ...props }: ButtonProps) {
return (
<button
className={cn(
"px-4 py-2 rounded-lg font-medium transition-colors",
variant === "primary" && "bg-primary-600 text-white hover:bg-primary-700",
variant === "secondary" && "bg-secondary-500 text-white hover:bg-secondary-600",
variant === "outline" && "border border-gray-300 hover:bg-gray-50",
className
)}
{...props}
/>
);
}
```
**Got:** `src/lib/cn.ts` exports a `cn()` function. `clsx` and `tailwind-merge` are installed as dependencies. Components use `cn()` to merge class names without conflicts.
**If fail:** If `clsx` or `tailwind-merge` are not found, run `npm install clsx tailwind-merge`. With TypeScript reporting type errors in `cn.ts`, verify the `ClassValue` type is imported from `clsx`.
### Step 5: Add Dark Mode Support
Update `tailwind.config.ts`:
```typescript
const config: Config = {
darkMode: "class", // or "media" for system preference
// ... rest of config
};
```
Toggle implementation:
```tsx
"use client";
import { useEffect, useState } from "react";
export function ThemeToggle() {
const [dark, setDark] = useState(false);
useEffect(() => {
document.documentElement.classList.toggle("dark", dark);
}, [dark]);
return (
<button onClick={() => setDark(!dark)}>
{dark ? "Light" : "Dark"} Mode
</button>
);
}
```
**Got:** Dark mode toggles correctly between light and dark themes. The `dark` class is applied to the `<html>` element, and `dark:` prefixed utility classes respond accordingly.
**If fail:** If dark mode does not toggle, verify `darkMode: "class"` is set in `tailwind.config.ts`. Ensure the `dark` class is toggled on the `<html>` element (not `<body>`). For system-preference mode, use `darkMode: "media"` instead.
### Step 6: Add Plugins (Optional)
```bash
npm install -D @tailwindcss/typography @tailwindcss/forms
```
```typescript
// tailwind.config.ts
import typography from "@tailwindcss/typography";
import forms from "@tailwindcss/forms";
const config: Config = {
// ...
plugins: [typography, forms],
};
```
**Got:** Plugins are installed as dev dependencies and registered in the `plugins` array of `tailwind.config.ts`. Plugin-provided classes (e.g., `prose` from typography, styled form elements from forms) are available in components.
**If fail:** If plugin classes do not render, verify the plugin is both installed (`npm ls @tailwindcss/typography`) and added to the `plugins` array. Restart the dev server after config changes.
## Validation
- [ ] Tailwind classes render correctly in the browser
- [ ] Custom theme values (colors, fonts, spacing) work
- [ ] `cn()` utility merges classes without conflicts
- [ ] Dark mode toggles correctly
- [ ] TypeScript shows no errors in config or components
- [ ] Production build purges unused styles
## Pitfalls
- **Content paths missing**: If classes don't render, check `content` array in config matches your file locations
- **Class conflicts**: Use `tailwind-merge` (via `cn()`) to prevent conflicting utility classes
- **Custom values not working**: Ensure custom values are under `extend` (to add) not at theme root (which replaces defaults)
- **Dark mode not toggling**: Check `darkMode` setting and that the `dark` class is on `<html>` not `<body>`
## Related Skills
- `scaffold-nextjs-app` - project setup before Tailwind configuration
- `deploy-to-vercel` - deploy the styled applicationRelated Skills
setup-wsl-dev-environment
Set up a WSL2 development environment on Windows including shell configuration, essential tools, Git, SSH keys, Node.js, Python, and cross-platform path management. Use when setting up a new Windows machine for development, configuring WSL2 for the first time, adding development tools to an existing WSL installation, or setting up cross-platform workflows that combine WSL and Windows tools.
setup-uptime-checks
Configure external uptime monitoring using Blackbox Exporter and Prometheus. Implement SSL certificate monitoring, HTTP endpoint health checks, and status pages for customer-facing visibility. Use when monitoring customer-facing endpoints such as APIs and websites, tracking SSL certificate expiration, validating service availability from multiple regions, creating public status pages, or meeting SLA requirements for uptime reporting.
setup-service-mesh
Deploy and configure a service mesh (Istio or Linkerd) to enable secure service-to-service communication, traffic management, observability, and policy enforcement in Kubernetes clusters. Covers installation, mTLS, traffic routing, circuit breaking, and integration with monitoring tools. Use when microservices need encrypted service-to-service communication, fine-grained traffic control for canary or A/B deployments, observability across all service interactions without application changes, or consistent circuit breaking and retry policies.
setup-putior-ci
Set up GitHub Actions CI/CD to automatically regenerate putior workflow diagrams on push. Covers workflow YAML creation, R script for diagram generation with sentinel markers, auto-commit of updated diagrams, and README sentinel integration for in-place diagram updates. Use when workflow diagrams should always reflect the current state of the code, when multiple contributors may change workflow-affecting code, or when replacing manual diagram regeneration with an automated CI/CD pipeline.
setup-prometheus-monitoring
Configure Prometheus for time-series metrics collection, including scrape configurations, service discovery, recording rules, and federation patterns for multi-cluster deployments. Use when setting up centralized metrics collection for microservices, implementing time-series monitoring for application and infrastructure, establishing a foundation for SLO/SLI tracking and alerting, or migrating from legacy monitoring solutions to a modern observability stack.
setup-local-kubernetes
Set up a local Kubernetes development environment using kind, k3d, or minikube for fast inner-loop development. Covers cluster creation, ingress configuration, local registry setup, and integration with development tools like Skaffold and Tilt for automatic rebuild and redeploy workflows. Use when needing a local Kubernetes environment for development, testing manifests or Helm charts before production deployment, wanting fast automatic rebuild-and-redeploy cycles, or learning Kubernetes without cloud costs.
setup-gxp-r-project
Set up an R project structure compliant with GxP regulations (21 CFR Part 11, EU Annex 11). Covers validated environments, qualification documentation, change control, and electronic records requirements. Use when starting an R analysis project in a regulated environment (pharma, biotech, medical devices), setting up R for clinical trial analysis, creating a validated computing environment for regulatory submissions, or implementing 21 CFR Part 11 or EU Annex 11 requirements.
setup-github-actions-ci
Configure GitHub Actions CI/CD for R packages including R CMD check on multiple platforms, test coverage reporting, and pkgdown site deployment. Uses r-lib/actions for standard workflows. Use when setting up CI/CD for a new R package, adding multi-platform testing to an existing package, configuring automated pkgdown site deployment, or adding code coverage reporting to a repository.
setup-docker-compose
Configure Docker Compose for multi-container R development environments. Covers service definitions, volume mounts, networking, environment variables, and dev vs production configurations. Use to run R alongside other services (databases, APIs), set up a reproducible R dev environment, orchestrate an R-based MCP server container, or manage environment variables and volume mounts for R projects.
setup-container-registry
Configure container image registries including GitHub Container Registry (ghcr.io), Docker Hub, and Harbor with automated image scanning, tagging strategies, retention policies, and CI/CD integration for secure image distribution. Use when setting up a private container registry, migrating from Docker Hub to self-hosted registries, implementing vulnerability scanning in CI/CD pipelines, managing multi-architecture images, enforcing image signing, or configuring automatic cleanup and retention policies.
setup-compose-stack
Configure general-purpose Docker Compose stacks for common application patterns. Covers web app + database + cache + worker services, named volumes, networks, health checks, depends_on, environment management, and profiles. Use to run a web app with a database or cache, set up a dev environment with multiple services, orchestrate background workers alongside an API, or create reproducible multi-service environments.
setup-automl-pipeline
Configure automated ML pipelines using Optuna or Ray Tune for hyperparameter optimization. Implement efficient search strategies (Hyperband, ASHA), define search spaces, and set up early stopping to find optimal model configurations with minimal manual tuning. Use when starting a new ML project, retraining with new data and re-optimizing hyperparameters, comparing multiple algorithms, or when the team lacks deep expertise in specific algorithm hyperparameters.