Tailwind CSS Academy · 강의

팀 규칙과 스타일 가이드

클래스 순서, 컴포넌트 이름 지정, @apply 사용 시점, 일회성 임의 값의 일관된 처리 방법을 포함하는 팀 스타일 가이드를 정의합니다.

레슨 4/413개 단계

팀 규칙과 스타일 가이드은(는) CoddyKit의 무료 Tailwind CSS Academy 강의입니다. 이것은 4개 중 4번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Tailwind CSS Academy 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Tailwind CSS Academy 강의에는 총 4개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

Why Teams Need a Tailwind Style Guide

Without agreed conventions, Tailwind projects drift into inconsistency. One developer writes p-4 everywhere, another uses px-4 py-4. One uses @apply liberally, another avoids it entirely. A team style guide documents the decisions your team has made so that everyone writes Tailwind the same way, making code reviews faster and the codebase easier to maintain.

Defining Class Ordering Conventions

Even with the Prettier plugin enforcing order automatically, your style guide should document why the canonical order is used and what it looks like so developers understand it rather than just following it blindly. Include the group order — layout, sizing, spacing, typography, visual, interactive — so team members can predict where a class belongs.

<!-- Canonical order groups -->
<div class="
  flex items-center gap-4    /* Layout */
  w-full max-w-md            /* Sizing */
  p-6 mx-auto                /* Spacing */
  text-sm font-medium        /* Typography */
  bg-white rounded-lg shadow /* Visual */
  hover:shadow-md transition  /* Interactive */
">

When to Use @apply

A common source of disagreement is when to extract utilities with @apply. Define a clear rule: for example, use @apply only when a pattern repeats more than three times across different components AND cannot be solved with a shared JSX or template component. This prevents premature abstraction while catching genuine duplication.

/* ALLOWED: repeated button pattern with no JSX component possible */
.btn-primary {
  @apply rounded-lg bg-blue-600 px-4 py-2 text-sm font-semibold text-white hover:bg-blue-700;
}

/* DISCOURAGED: abstracting a one-off layout that appears only once */
.hero-section {
  @apply flex min-h-screen flex-col items-center justify-center bg-gray-50;
}

Arbitrary Value Conventions

Tailwind's bracket notation like w-[347px] is powerful but can lead to a proliferation of magic numbers that are hard to maintain. Your style guide should require that arbitrary values be justified in a comment, and that values appearing more than once be added to the theme's extend block as a named token instead.

<!-- DISCOURAGED: unexplained magic number -->
<div class="h-[347px]">

<!-- BETTER: explain the constraint with a comment -->
<!-- Height matches the sidebar for visual alignment -->
<div class="h-[347px]">

<!-- BEST: promote to a named token in the config -->
<!-- tailwind.config.js: extend.height: { sidebar: '347px' } -->
<div class="h-sidebar">

Safelist Governance

Every entry in the safelist adds cost to every build. Your style guide should require that safelisted classes include a comment explaining why they cannot be statically detected. Create a safelist audit schedule — for example, quarterly — to remove entries for features that have been removed or refactored.

// tailwind.config.js
module.exports = {
  safelist: [
    // REASON: color comes from CMS content, cannot be statically detected
    // REVIEW DATE: 2026-Q3
    { pattern: /bg-(red|green|blue|yellow)-(100|500)/ },

    // REASON: toast severity classes set by JS at runtime
    'border-red-500',
    'border-green-500',
  ],
};

Component Naming Conventions

If your project uses @apply to create component classes, establish a naming convention. BEM-inspired names like .btn-primary and .card-body are a common choice. Document which naming pattern your team uses and ensure custom component classes never conflict with Tailwind's own utility names.

/* Naming convention: {component}-{variant} */
.btn { @apply rounded-lg px-4 py-2 font-semibold; }
.btn-primary { @apply btn bg-blue-600 text-white hover:bg-blue-700; }
.btn-outline { @apply btn border border-blue-600 text-blue-600 hover:bg-blue-50; }

.card { @apply rounded-xl bg-white shadow; }
.card-header { @apply border-b border-gray-100 p-4 font-semibold; }
.card-body { @apply p-4; }

Responsive Prefix Conventions

Document how your team handles responsive design. Common conventions include mobile-first always (base styles are mobile, prefixes add larger-screen behavior), using only a subset of breakpoints (e.g., md and lg only), and never applying a prefix without also defining the base case so styles cascade correctly.

<!-- GOOD: mobile-first base, then larger breakpoints -->
<div class="flex-col gap-4 md:flex-row md:gap-6 lg:gap-8">

<!-- CONFUSING: responsive prefix without a base style -->
<div class="md:flex-row">
<!-- What displays on mobile? The browser's UA default — unpredictable -->

Dark Mode Conventions

Choose and document one dark mode strategy for the entire project — either the class strategy or the media strategy — and never mix them. Specify which elements always need a dark variant (backgrounds, text, borders) and which can inherit. Include a checklist for reviewing new components for dark mode completeness before merging.

/* Documented decision: we use class strategy */
/* tailwind.config.js: darkMode: 'class' */

/* Component dark mode checklist:
   [ ] bg-* has a dark:bg-* variant
   [ ] text-* has a dark:text-* variant
   [ ] border-* has a dark:border-* variant
   [ ] ring-* has a dark:ring-* variant if used as focus indicator
*/

<div class="bg-white dark:bg-gray-900 text-gray-900 dark:text-gray-100">

Pull Request Review Checklist

Embed Tailwind conventions into your PR review process. A short checklist in the PR template reminds both author and reviewer to verify key conventions. Items might include: classes are sorted, no unsafed dynamic class construction, arbitrary values have a comment, dark mode variants are complete, and no contradicting utilities are present.

## Tailwind Checklist
- [ ] Classes sorted (Prettier ran)
- [ ] No typos (ESLint passed)
- [ ] Arbitrary values explained with comments
- [ ] Dark mode variants added for new surfaces
- [ ] No dynamic class concatenation without safelist
- [ ] Responsive base styles defined before breakpoint prefixes

Documenting the Style Guide

Write the style guide in a STYLE_GUIDE.md file committed to the repository. Keep it close to the code, not in a separate wiki that goes stale. Each convention should include a brief rationale so new team members understand the why, making it easier to accept and follow. Review the guide quarterly and update it as the project evolves.

# Tailwind CSS Style Guide

## 1. Class Ordering
Use Prettier plugin — no manual sorting required.

## 2. @apply Usage
Only for patterns repeated 3+ times with no component solution.

## 3. Arbitrary Values
Add a comment. If used 2+ times, promote to theme.extend.

## 4. Dark Mode
Class strategy. Every new background and text color needs dark variant.

Onboarding New Developers

A style guide is only effective if new developers read it. Include a link to the Tailwind style guide in your project's README and in the onboarding checklist for new team members. Consider adding a short quiz or exercise that lets new developers apply the conventions on a practice component before touching production code.

# README.md

## Getting Started
1. `npm install`
2. Read [STYLE_GUIDE.md](./STYLE_GUIDE.md) before writing any Tailwind classes
3. Enable the recommended VS Code extensions from `.vscode/extensions.json`
4. Run `npm run lint && npm run format:check` before every commit

Quick Check

Test your understanding of Tailwind CSS Mastery concepts from this lesson.

Lesson Recap

In this lesson you learned: defining @apply and arbitrary value conventions to prevent misuse, embedding conventions into PR checklists for consistent review, and documenting the style guide in the repository so it stays up to date. Next up we build a complete landing page hero and navigation section.

무료로 시작

AI 튜터와 함께 HTML을(를) 배우세요 — 무료

브라우저에서 실제 코드를 작성하고 실행하며, 24/7 AI 튜터로부터 즉각적인 도움을 받고, 웹이나 앱에서 중단한 부분부터 계속 학습하세요.

코스
30
레슨
120

자주 묻는 질문

“팀 규칙과 스타일 가이드” 강의는 무료인가요?

네 — “팀 규칙과 스타일 가이드” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Tailwind CSS Academy 강의 전체를 잠금 해제할 수 있습니다. Tailwind CSS Academy 강의에는 총 4개의 강의가 포함되어 있습니다.

“팀 규칙과 스타일 가이드”에서 뭘 배우나요?

클래스 순서, 컴포넌트 이름 지정, @apply 사용 시점, 일회성 임의 값의 일관된 처리 방법을 포함하는 팀 스타일 가이드를 정의합니다. 브라우저에서 직접 실행하는 실습 코드로 Tailwind CSS Academy을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

Tailwind CSS Academy을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 Tailwind CSS Academy은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 4번째 강의입니다.

“팀 규칙과 스타일 가이드” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 Tailwind CSS Academy 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 Tailwind CSS Academy 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. CSS 출력 점검
  2. 클래스 정렬과 Prettier 플러그인
  3. ESLint로 Tailwind 린트하기
  4. 팀 규칙과 스타일 가이드
← Tailwind CSS Academy(으)로 돌아가기