MCP HubMCP Hub
스킬 목록으로 돌아가기

setup-tailwind-typescript

pjt222
업데이트됨 2 days ago
6 조회
17
2
17
GitHub에서 보기
디자인reactaidesign

정보

이 스킬은 TypeScript 기반 Next.js 또는 React 프로젝트에서 Tailwind CSS를 설치 및 설정하여 구성합니다. 커스텀 테마 확장, 타입 안전 스타일링 유틸리티, 디자인 시스템을 위한 컴포넌트 패턴을 활성화합니다. 기존 TypeScript 프로젝트에 Tailwind를 추가하고 완전한 타입 안전성을 갖춘 플러그인을 구성할 때 사용하세요.

빠른 설치

Claude Code

추천
기본
npx skills add pjt222/agent-almanac -a claude-code
플러그인 명령대체
/plugin add https://github.com/pjt222/agent-almanac
Git 클론대체
git clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/setup-tailwind-typescript

Claude Code에서 이 명령을 복사하여 붙여넣어 스킬을 설치하세요

문서

Set Up Tailwind CSS with TypeScript

Configure Tailwind CSS in TS project w/ custom theme, utilities, type-safe patterns.

Use When

  • Add Tailwind to existing TS project
  • Customize theme for design system
  • Type-safe component styling
  • Configure plugins + ext

In

  • Required: TS project (Next.js, Vite, standalone React)
  • Optional: Design tokens (colors, spacing, fonts)
  • Optional: Plugins to include

Do

Step 1: Install Tailwind

npm install -D tailwindcss @tailwindcss/postcss postcss

Next.js (if not included):

npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p

tailwindcss, postcss, autoprefixer as dev deps. Next.js → tailwind.config.ts + postcss.config.js generated.

If err: npx tailwindcss init fails → install Tailwind first w/ npm install -D tailwindcss + retry. Monorepo → run from app root, not workspace root.

Step 2: tailwind.config.ts

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;

→ Has content array matching paths, custom colors+fonts under theme.extend, proper TS typing w/ Config import.

If err: custom classes don't render → verify content paths match dir. Glob patterns relative to root. Missing → Tailwind won't scan.

Step 3: Global Styles

Edit src/app/globals.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;
  }
}

globals.css has 3 directives + custom base+component layer. Imported in root layout.

If err: not applied → verify imported in layout.tsx (or _app.tsx for Pages). Directives present, not commented.

Step 4: Type-Safe Utility Helpers

Create src/lib/cn.ts:

import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";

export function cn(...inputs: ClassValue[]) {
  return twMerge(clsx(inputs));
}

Install:

npm install clsx tailwind-merge

Usage:

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}
    />
  );
}

src/lib/cn.ts exports cn(). clsx + tailwind-merge installed. Components use cn() to merge class names w/o conflicts.

If err: clsx|tailwind-merge not found → npm install clsx tailwind-merge. TS errs in cn.ts → verify ClassValue imported from clsx.

Step 5: Dark Mode

Update tailwind.config.ts:

const config: Config = {
  darkMode: "class", // or "media" for system preference
  // ... rest of config
};

Toggle:

"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>
  );
}

→ Dark toggles correct between light+dark. dark class on <html>, dark: prefixed classes respond.

If err: not toggling → verify darkMode: "class". dark on <html> not <body>. System-pref → darkMode: "media".

Step 6: Plugins (Optional)

npm install -D @tailwindcss/typography @tailwindcss/forms
// tailwind.config.ts
import typography from "@tailwindcss/typography";
import forms from "@tailwindcss/forms";

const config: Config = {
  // ...
  plugins: [typography, forms],
};

→ Plugins installed dev deps + registered in plugins array. Plugin classes (prose, styled forms) available.

If err: plugin classes don't render → verify installed (npm ls @tailwindcss/typography) + in plugins array. Restart dev server after config changes.

Check

  • Tailwind classes render in browser
  • Custom theme (colors, fonts, spacing) works
  • cn() merges w/o conflicts
  • Dark mode toggles
  • TS no errs in config|components
  • Prod build purges unused

Traps

  • Content paths missing: Classes don't render → check content array matches files
  • Class conflicts: Use tailwind-merge (via cn()) → prevent conflicting
  • Custom vals not working: Under extend (to add) not theme root (replaces defaults)
  • Dark mode not toggling: Check darkMode + dark on <html> not <body>

  • scaffold-nextjs-app — project setup pre-Tailwind
  • deploy-to-vercel — deploy styled app

GitHub 저장소

pjt222/agent-almanac
경로: i18n/caveman-ultra/skills/setup-tailwind-typescript
0
agentsagentskillsai-assisted-developmentclaude-codeskillsteams

연관 스킬

executing-plans

디자인

executing-plans 스킬은 검토 체크포인트가 포함된 통제된 배치로 실행할 완전한 구현 계획이 있을 때 사용합니다. 이 스킬은 계획을 불러와 비판적으로 검토한 후, 소규모 배치(기본값 3개 작업)로 작업을 실행하면서 각 배치 사이에 진행 상황을 아키텍트 검토를 위해 보고합니다. 이를 통해 내재된 품질 관리 체크포인트를 갖춘 체계적인 구현이 보장됩니다.

스킬 보기

requesting-code-review

디자인

이 스킬은 코드 변경 사항을 요구 사항에 따라 분석하기 위해 코드 리뷰어 하위 에이전트를 호출합니다. 작업 완료 후, 주요 기능 구현 후, 또는 메인 브랜치에 병합하기 전에 사용해야 합니다. 이 리뷰는 현재 구현체와 원래 계획을 비교하여 문제를 조기에 발견하는 데 도움이 됩니다.

스킬 보기

connect-mcp-server

디자인

이 스킬은 개발자들이 HTTP, stdio 또는 SSE 전송 방식을 통해 MCP 서버를 Claude Code에 연결하는 포괄적인 가이드를 제공합니다. GitHub, Notion 및 사용자 정의 API와 같은 외부 서비스를 통합하기 위한 설치, 구성, 인증 및 보안을 다룹니다. MCP 통합 설정, 외부 도구 구성 또는 Claude의 모델 컨텍스트 프로토콜 작업 시 활용하세요.

스킬 보기

web-cli-teleport

디자인

이 스킬은 작업 분석을 기반으로 개발자가 Claude Code 웹 인터페이스와 CLI 인터페이스 중 선택할 수 있도록 돕고, 두 환경 간 원활한 세션 텔레포트를 가능하게 합니다. 웹, CLI 또는 모바일 환경 전환 시 세션 상태와 컨텍스트를 관리하여 워크플로를 최적화합니다. 다양한 단계에서 서로 다른 도구가 필요한 복잡한 프로젝트에 사용하세요.

스킬 보기