--- name: tailwind_mastery router_kit: AIKit description: Tailwind CSS v4, design tokens, responsive patterns ve utility-first CSS best practices. metadata: skillport: category: design tags: [agents, algorithms, artificial intelligence, automation, chatbots, cognitive services, deep learning, embeddings, frameworks, generative ai, inference, large language models, llm, machine learning, model fine-tuning, natural language processing, neural networks, nlp, openai, prompt engineering, rag, retrieval augmented generation, tailwind mastery, tools, vector databases, workflow automation] - responsive --- # 🎨 Tailwind Mastery > Tailwind CSS v4 ve utility-first CSS best practices rehberi. --- ## 📋 İçindekiler 1. [Tailwind v4 Yenilikleri](#1-tailwind-v4-yenilikleri) 2. [Design System](#2-design-system) 3. [Responsive Patterns](#3-responsive-patterns) 4. [Component Patterns](#4-component-patterns) 5. [Dark Mode](#5-dark-mode) 6. [Performance](#6-performance) --- ## 1. Tailwind v4 Yenilikleri ### CSS-First Configuration ```css /* app.css */ @import "tailwindcss"; @theme { --color-primary: #3b82f6; --color-secondary: #10b981; --font-display: "Inter", sans-serif; --spacing-128: 32rem; } ``` ### Otomatik Content Detection ```css /* v4'te content config'e gerek yok */ /* Otomatik olarak tüm dosyalar taranır */ ``` ### Native CSS Features ```css /* Container Queries */ @container (min-width: 400px) { .card { /* styles */ } } /* v4 utility */
...
``` --- ## 2. Design System ### Spacing Scale ```html
``` ### Typography Scale ```html

``` ### Color System ```html

``` ### Custom Theme ```css @theme { /* Colors */ --color-brand-50: #eff6ff; --color-brand-500: #3b82f6; --color-brand-900: #1e3a8a; /* Typography */ --font-sans: "Inter", system-ui, sans-serif; --font-mono: "Fira Code", monospace; /* Shadows */ --shadow-soft: 0 2px 15px -3px rgb(0 0 0 / 0.1); } ``` --- ## 3. Responsive Patterns ### Breakpoints ```html
``` ### Responsive Grid ```html
Item 1
Item 2
Item 3
``` ### Responsive Typography ```html

Responsive Title

``` ### Hide/Show ```html
Mobile only
``` --- ## 4. Component Patterns ### Card ```html

Title

Content

``` ### Button Variants ```html ``` ### Input ```html ``` ### Flex Patterns ```html
``` --- ## 5. Dark Mode ### Class Strategy ```html
``` ### System Preference ```javascript // tailwind.config.js (v3) veya @media (v4) if (window.matchMedia('(prefers-color-scheme: dark)').matches) { document.documentElement.classList.add('dark'); } ``` ### Toggle Implementation ```javascript function toggleDarkMode() { document.documentElement.classList.toggle('dark'); localStorage.theme = document.documentElement.classList.contains('dark') ? 'dark' : 'light'; } ``` --- ## 6. Performance ### Purge Optimization ```css /* v4: Otomatik - sadece kullanılan class'lar bundle'a dahil */ ``` ### Avoid Dynamic Classes ```html
``` ### Safelist (Gerekirse) ```javascript // tailwind.config.js module.exports = { safelist: [ 'bg-red-500', 'bg-green-500', { pattern: /^bg-(red|green|blue)-/ }, ], }; ``` ### Production Build ```bash # Minified CSS NODE_ENV=production npx tailwindcss -i input.css -o output.css --minify ``` --- ## 🎯 Quick Reference ### Spacing: `p-{n}`, `m-{n}`, `gap-{n}` ### Sizing: `w-{n}`, `h-{n}`, `size-{n}` ### Flex: `flex`, `items-center`, `justify-between` ### Grid: `grid`, `grid-cols-{n}`, `gap-{n}` ### Text: `text-{size}`, `font-{weight}`, `text-{color}` ### Border: `border`, `border-{n}`, `rounded-{size}` ### Shadow: `shadow`, `shadow-{size}` ### Transition: `transition`, `duration-{ms}`, `ease-{type}` ## 🔄 Workflow > **Kaynak:** [Tailwind CSS v4.0 Release](https://tailwindcss.com/blog/tailwindcss-v4-beta) & [Adam Wathan's Design Tips](https://twitter.com/adamwathan) ### Aşama 1: Foundation & Theme Setup - [ ] **V4 Configuration**: `tailwind.config.js` yerine CSS-first (`@theme`) konfigürasyonunu kurgula. - [ ] **Design Tokens Ingestion**: Renk paleti, typography scale ve spacing değerlerini CSS değişkenleri olarak tanımla. - [ ] **Base Style Reset**: `@layer base` kullanarak global stil sıfırlama (Preflight) ve font yüklemelerini yap. ### Aşama 2: Utility-First Implementation - [ ] **Layout Orchestration**: Sayfa yapısını `Grid` ve `Flex` kullanarak duyarlı (Responsive) şekilde kur. - [ ] **Interaction Variants**: Hover, focus, active ve group-hover state'lerini kullanarak etkileşimi artır. - [ ] **Modern CSS Utilities**: `@container` queries ve `logical properties` (margin-inline vb.) kullanımını önceliklendir. ### Aşama 3: Polish & Optimization - [ ] **Visual Hierarchy Audit**: `shadow`, `opacity` ve `z-index` values'larının hiyerarşiye uygunluğunu kontrol et. - [ ] **Dark Mode Sync**: `dark:` variant'larının semantik renklerle uyumlu olduğunu doğrula. - [ ] **Bundle Check**: Production build sonrası CSS boyutunu ve gereksiz class kullanımını (Unused CSS) denetle. ### Kontrol Noktaları | Aşama | Doğrulama | |-------|-----------| | 1 | Karmaşık komponentler için `@apply` yerine "extract to component" stratejisi mi kullanıldı? | | 2 | Yazı tipi (Typography) okunabilirliği kontrast testinden geçiyor mu? | | 3 | Responsive kırılmalar (sm, md, lg) içerik odaklı mı? | --- *Tailwind Mastery v1.5 - With Workflow*