Communitygithub.com

marnixGeerkens/rocketlauncher-claude-code

Tailwind CSS v4 设计原则:CSS 优先的配置、容器查询、现代模式与设计令牌架构。

rocketlauncher-claude-code 是什么?

该技能为开发者提供了一套基于 Tailwind CSS v4(2025 年版本)的现代实用优先 CSS 模式指南。它详细解释了从 v3 到 v4 的关键架构变化,例如从 JavaScript 配置文件转向 CSS 原生的 `@theme` 指令,以及引入基于 Rust 的 Oxide 引擎带来的十倍性能提升。技能重点介绍了 CSS 优先的配置方法、语义化设计令牌的建立、容器查询的原生支持,以及如何构建响应式、支持深色模式的现代布局。此外,它还涵盖了 OKLCH 色彩空间、排版系统、动画与过渡最佳实践,并明确指出了应避免的反模式,帮助开发者高效且符合标准地使用 Tailwind CSS v4。

兼容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/marnixGeerkens/rocketlauncher-claude-code/tree/HEAD/components/skills/creative-design/tailwind-patterns

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

Tailwind CSS 模式(v4 - 2025)

使用 CSS 原生配置的现代实用优先 CSS。


1. Tailwind v4 架构

与 v3 的变化

v3(旧版)v4(当前)
tailwind.config.js基于 CSS 的 @theme 指令
PostCSS 插件Oxide 引擎(快 10 倍)
JIT 模式原生、始终开启
插件系统CSS 原生特性
@apply 指令仍然可用,但不推荐

v4 核心概念

概念描述
CSS 优先在 CSS 中配置,而非 JavaScript
Oxide 引擎基于 Rust 的编译器,速度更快
原生嵌套无需 PostCSS 即可使用 CSS 嵌套
CSS 变量所有令牌都暴露为 --* 变量

2. 基于 CSS 的配置

主题定义

@theme {
  /* 颜色 - 使用语义化名称 */
  --color-primary: oklch(0.7 0.15 250);
  --color-surface: oklch(0.98 0 0);
  --color-surface-dark: oklch(0.15 0 0);
  
  /* 间距比例 */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 2rem;
  
  /* 排版 */
  --font-sans: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

何时扩展与覆盖

操作使用场景
扩展在默认值之外添加新值
覆盖完全替换默认比例
语义化令牌项目特定命名(primary, surface)

3. 容器查询(v4 原生)

断点 vs 容器

类型响应对象
断点(md:)视口宽度
容器(@container)父元素宽度

容器查询用法

模式类名
定义容器在父元素上使用 @container
容器断点在子元素上使用 @sm:、@md:、@lg:
命名容器使用 @container/card 提高特异性

何时使用

场景使用方式
页面级布局视口断点
组件级响应容器查询
可复用组件容器查询(上下文无关)

4. 响应式设计

断点系统

前缀最小宽度目标设备
(无)0px移动优先基础
sm:640px大屏手机 / 小平板
md:768px平板
lg:1024px笔记本电脑
xl:1280px桌面
2xl:1536px大屏桌面

移动优先原则

  1. 先编写移动端样式(无前缀)
  2. 使用前缀添加更大屏幕的覆盖样式
  3. 示例:w-full md:w-1/2 lg:w-1/3

5. 深色模式

配置策略

方法行为使用场景
class通过 .dark 类切换手动主题切换器
media跟随系统偏好无用户控制
selector自定义选择器(v4)复杂主题

深色模式模式

元素亮色模式深色模式
背景bg-whitedark:bg-zinc-900
文字text-zinc-900dark:text-zinc-100
边框border-zinc-200dark:border-zinc-700

6. 现代布局模式

Flexbox 模式

模式类名
居中(双轴)flex items-center justify-center
垂直堆叠flex flex-col gap-4
水平行flex gap-4
两端对齐flex justify-between items-center
换行网格flex flex-wrap gap-4

Grid 模式

模式类名
自适应填充grid grid-cols-[repeat(auto-fit,minmax(250px,1fr))]
非对称(Bento)grid grid-cols-3 grid-rows-2 配合 span
侧边栏布局grid grid-cols-[auto_1fr]

注意: 优先使用非对称/Bento 布局,而非对称的三列网格。


7. 现代颜色系统

OKLCH vs RGB/HSL

格式优势
OKLCH感知均匀,更适合设计
HSL直观的色相/饱和度
RGB向后兼容

颜色令牌架构

层级示例用途
原始值--blue-500原始颜色值
语义化--color-primary基于用途的命名
组件级--button-bg特定于组件

8. 排版系统

字体堆叠模式

类型推荐
无衬线体'Inter', 'SF Pro', system-ui, sans-serif
等宽体'JetBrains Mono', 'Fira Code', monospace
展示字体'Outfit', 'Poppins', sans-serif

字号比例

类名大小用途
text-xs0.75rem标签、说明文字
text-sm0.875rem次要文字
text-base1rem正文
text-lg1.125rem引导文字
text-xl+1.25rem+标题

9. 动画与过渡

内置动画

类名效果
animate-spin持续旋转
animate-ping注意脉冲
animate-pulse微妙的透明度脉冲
animate-bounce弹跳效果

过渡模式

模式类名
所有属性transition-all duration-200
指定属性transition-colors duration-150
缓动函数ease-out 或 ease-in-out
悬停效果hover:scale-105 transition-transform

10. 组件提取

何时提取

信号操作
相同类组合出现 3 次以上提取为组件
复杂的状态变体提取为组件
设计系统元素提取并记录

提取方法

方法使用场景
React/Vue 组件动态、需要 JS
CSS 中的 @apply静态、无需 JS
设计令牌可复用的值

11. 反模式

不要这样做建议这样做
到处使用任意值使用设计系统比例
使用 !important正确修复特异性
使用内联 style=使用工具类
重复长的类列表提取组件
混合 v3 和 v4 配置完全迁移到 CSS 优先
大量使用 @apply优先使用组件

12. 性能原则

原则实现方式
清除未使用v4 中自动完成
避免动态不要使用模板字符串类名
使用 Oxidev4 默认开启,快 10 倍
缓存构建CI/CD 缓存

记住: Tailwind v4 是 CSS 优先的。拥抱 CSS 变量、容器查询和原生特性。配置文件现在是可选的。

Individual skills in this repo

This repo contains 13 individual skills — each has its own dedicated page.

marnixGeerkens/rocketlauncher-claude-code

When the user wants to optimize, improve, or increase conversions on any marketing page — including homepage, landing pages, pricing pages, feature pages, or blog posts. Also use when the user says "CRO," "conversion rate optimization," "this page isn't converting," "improve conversions," or "why isn't this page working." For signup/registration flows, see signup-flow-cro. For post-signup activation, see onboarding-cro. For forms outside of signup, see form-cro. For popups/modals, see popup-cro.

marnixGeerkens/rocketlauncher-claude-code

Balance visual design with ATS compatibility for creative roles. Use when the user is in design, art, writing, marketing creative, or any visual/creative field and needs a resume that looks distinctive but still parses.

marnixGeerkens/rocketlauncher-claude-code

Transform resume bullets into detailed portfolio case studies with context, action, and outcome. Use when the user mentions portfolio, case study, project write-up, or expanding a resume bullet into a longer narrative.

marnixGeerkens/rocketlauncher-claude-code

Expert in building portfolios that actually land jobs and clients - not just showing work, but creating memorable experiences. Covers developer portfolios, designer portfolios, creative portfolios, and portfolios that convert visitors into opportunities. Use when: portfolio, personal website, showcase work, developer portfolio, designer portfolio.

marnixGeerkens/rocketlauncher-claude-code

Frontend development patterns for React, Next.js, state management, performance optimization, and UI best practices.

marnixGeerkens/rocketlauncher-claude-code

Frontend development guidelines for React/TypeScript applications. Modern patterns including Suspense, lazy loading, useSuspenseQuery, file organization with features directory, MUI v7 styling, TanStack Router, performance optimization, and TypeScript best practices. Use when creating components, pages, features, fetching data, styling, routing, or working with frontend code.

marnixGeerkens/rocketlauncher-claude-code

Next.js App Router principles. Server Components, data fetching, routing patterns.

marnixGeerkens/rocketlauncher-claude-code

Expert integration of Supabase Auth with Next.js App Router Use when: supabase auth next, authentication next.js, login supabase, auth middleware, protected route.

marnixGeerkens/rocketlauncher-claude-code

Comprehensive frontend development skill for building modern, performant web applications using ReactJS, NextJS, TypeScript, Tailwind CSS. Includes component scaffolding, performance optimization, bundle analysis, and UI best practices. Use when developing frontend features, optimizing performance, implementing UI/UX designs, managing state, or reviewing frontend code.

marnixGeerkens/rocketlauncher-claude-code

Create API handoff documentation for frontend developers. Use when backend work is complete and needs to be documented for frontend integration, or user says 'create handoff', 'document API', 'frontend handoff', or 'API documentation'.

marnixGeerkens/rocketlauncher-claude-code

Document frontend data needs for backend developers. Use when frontend needs to communicate API requirements to backend, or user says 'backend requirements', 'what data do I need', 'API requirements', or is describing data needs for a UI.

marnixGeerkens/rocketlauncher-claude-code

Comprehensive Python library for astronomy and astrophysics. This skill should be used when working with astronomical data including celestial coordinates, physical units, FITS files, cosmological calculations, time systems, tables, world coordinate systems (WCS), and astronomical data analysis. Use when tasks involve coordinate transformations, unit conversions, FITS file manipulation, cosmological distance calculations, time scale conversions, or astronomical data processing.

marnixGeerkens/rocketlauncher-claude-code

Comprehensive patterns for Next.js 14+ App Router architecture, Server Components, and modern full-stack React development.

相关技能