Tailwind CSS UI 提示词

为 Tailwind CSS 优化的 AI 提示词 — 响应式布局、组件模式、design tokens 和工具类优先样式。

Tailwind UI promptTailwind CSS component promptTailwind design promptTailwind layout promptshadcn UI promptTailwind responsive design

关于此主题

Tailwind CSS 是 AI 生成代码中最流行的工具类优先 CSS 框架。在提示 AI 工具生成 Tailwind 代码时,具体指定类名、断点、间距值和组件模式能产生显著更好的结果。本合集提供使用 Tailwind 语言优化的提示词,帮助 AI 工具生成具备响应式设计、暗黑模式支持和可访问标记的生产就绪代码。

提示词示例

AI 提示词示例

复制这些提示词,用你喜欢的 AI 工具生成Tailwind CSS UI 提示词设计。

响应式导航

General
Build a responsive navigation bar with Tailwind CSS. Desktop: horizontal nav with logo (left), links (center), and CTA button (right) using 'flex items-center justify-between max-w-7xl mx-auto px-6 h-16'. Mobile: hamburger menu button that toggles a full-screen overlay nav using 'fixed inset-0 bg-white z-50 flex flex-col items-center justify-center gap-8'. Breakpoint: 'md' for the switch. Include smooth transition with 'transition-all duration-300'. Support dark mode with 'dark:bg-zinc-950 dark:text-white'.

v0 组件网格

v0
Create a responsive card grid using shadcn/ui and Tailwind. Grid: 'grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6'. Each card: shadcn Card with CardHeader (image placeholder, aspect-video), CardContent (title in font-semibold, description in text-sm text-muted-foreground), CardFooter (price badge and action button). Cards should have 'hover:shadow-lg transition-shadow' and 'group' class for hover effects on the image (scale-105). Include skeleton loading state using shadcn Skeleton component.

Cursor 表单布局

Cursor
Build a multi-step form with Tailwind CSS in Next.js. Container: 'max-w-2xl mx-auto py-12 px-6'. Step indicator: horizontal dots connected by lines, active step highlighted. Each step: form fields using 'space-y-6' with labels in 'text-sm font-medium' and inputs in 'w-full px-3 py-2 border border-zinc-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:outline-none dark:bg-zinc-900 dark:border-zinc-700'. Navigation: 'flex justify-between mt-8' with Back/Next buttons. Animate step transitions with 'transition-opacity duration-200'.

Claude Design Tokens

Claude
Generate a Tailwind CSS configuration with a complete design token system. Include: custom color palette (primary, secondary, accent, success, warning, danger, each with 50-950 shades), spacing scale extending the default (adding 18, 22, 30 for fine-grained control), custom font family stack (sans, serif, mono), border-radius tokens (none, sm, md, lg, xl, full), box-shadow tokens (sm, md, lg, xl, glow), and custom animation tokens (fade-in, slide-up, scale-in). Also create CSS custom properties that mirror the tokens for use in non-Tailwind contexts. Output as a tailwind.config.ts file.

Tailwind v4 主题配置

General
Set up a Tailwind CSS v4 project theme using the CSS-first configuration (no tailwind.config.js). In globals.css: '@import "tailwindcss";' followed by an @theme block defining --color-brand-50 through --color-brand-950 (base #4f46e5), --font-sans: 'Inter', system-ui, --radius-card: 1rem, and --spacing-section: 6rem. Add a custom dark variant with '@custom-variant dark (&:where(.dark, .dark *))'. Demonstrate usage: a hero section with bg-brand-600 text-white, cards using rounded-[--radius-card], and section padding py-[--spacing-section]. Include one @utility definition for a text-balance helper. All interactive elements need focus-visible:ring-2 ring-brand-500.

v0 仪表盘外壳

v0
Create a responsive dashboard shell with shadcn/ui and Tailwind. Desktop: CSS grid 'grid-cols-[240px_1fr]' with a sidebar (border-r border-zinc-200 dark:border-zinc-800, nav items 'flex items-center gap-3 rounded-md px-3 py-2 text-sm hover:bg-zinc-100 dark:hover:bg-zinc-800', active item bg-zinc-100 font-medium). Mobile: sidebar becomes a shadcn Sheet triggered from the top bar. Top bar: h-14 with breadcrumbs, a search input (w-64, pl-9 with an absolute icon), and an avatar dropdown. Content: 'p-6 lg:p-8 space-y-6' with a 4-card stat row 'grid gap-4 sm:grid-cols-2 lg:grid-cols-4'. Sidebar nav needs aria-current on the active link.

Cursor 营销页区块

Cursor
Build three reusable marketing sections in Next.js with Tailwind. Hero: 'py-24 lg:py-32' with headline 'text-5xl lg:text-6xl font-bold tracking-tight text-balance', subtext 'mt-6 text-lg text-zinc-600 max-w-2xl mx-auto', dual CTAs (primary bg-zinc-900 text-white, secondary ring-1 ring-zinc-300). Logo cloud: 'grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-8 items-center' with grayscale logos gaining color on hover. Feature bento: 'grid lg:grid-cols-3 gap-4' where the first card spans lg:col-span-2, each 'rounded-2xl bg-zinc-50 p-8 ring-1 ring-zinc-200'. Dark mode via dark: variants throughout; headings must maintain 4.5:1 contrast in both themes.

Claude 数据表格组件

Claude
Generate a reusable TypeScript DataTable component styled purely with Tailwind. Wrapper: 'overflow-x-auto rounded-lg ring-1 ring-zinc-200 dark:ring-zinc-800'. Table: 'w-full text-sm', header 'bg-zinc-50 dark:bg-zinc-900 text-left text-xs font-medium uppercase tracking-wide text-zinc-500', cells 'px-4 py-3 border-t border-zinc-100 dark:border-zinc-800'. Features: sortable columns (chevron icons with aria-sort on th), row selection with a checkbox column, zebra striping via odd:bg-zinc-50/50, sticky header with 'sticky top-0', numeric columns right-aligned with tabular-nums, and a pagination footer 'flex items-center justify-between px-4 py-3'. Provide loading skeleton rows and an empty state. Use scope="col" on headers for screen readers.

适用场景

最佳使用场景

快速原型

用工具类优先 CSS 和 AI 工具快速构建功能原型。

设计系统实现

将 Figma 设计转化为 Tailwind 组件库。

全栈应用

使用一致的 Tailwind 样式构建完整的 Next.js/React 应用。

组件库

使用 Tailwind 变体和 shadcn/ui 创建可复用组件库。

常见问题

常见问题解答

如何为 AI 写更好的 Tailwind 提示词?
具体指定 Tailwind 类名:提到精确的断点(sm、md、lg、xl)、间距值(p-4、gap-6、my-8)、颜色(zinc-900、blue-500)和布局工具类(flex、grid、grid-cols-3)。适用时引用 shadcn/ui 组件名称。指定暗黑模式需求(dark: 前缀)。明确包含响应式行为。StyleKit 的提示词已预先用这些 Tailwind 特定细节优化。
大型项目中组织 Tailwind 的最佳方式是什么?
在 tailwind.config 中使用 design tokens(自定义颜色、间距、阴影),仅在组件 CSS 模块中(非全局)用 @apply 创建可复用组件类,使用 CSS 自定义属性处理会变化的主题值(暗黑模式、用户偏好),用一致的命名组织组件,利用 shadcn/ui 作为组件基础。通过将重复模式提取为组件来避免过长的 className 字符串。
StyleKit 如何与 Tailwind CSS 配合?
StyleKit 提供一个持续维护的视觉风格目录,每种风格都有 Tailwind 兼容的 design tokens(颜色、间距、圆角、阴影、排版)。你可以把这些 tokens 用于 Tailwind 工作流、AI 代码生成提示词,或复制带有 Tailwind 类名的组件配方。StyleKit 连接了设计意图与 Tailwind 实现之间的桥梁。
Tailwind CSS v4 有哪些变化?
Tailwind v4 把配置从 tailwind.config.js 移进了 CSS:通过 '@import "tailwindcss"' 引入,在 @theme 块中以 CSS 变量定义 tokens(--color-brand-500、--font-display、--breakpoint-3xl)。自定义工具类用 @utility,自定义变体用 @custom-variant,且每个 design token 都自动暴露为原生 CSS 变量,可用 var() 读取。新引擎(Oxide)显著更快,内容检测自动完成(不再需要 content 数组),任意值和容器查询均为内置。大多数 v3 工具类无需改动;迁移主要涉及配置、插件和 @apply 的用法。
Tailwind 中该不该用 @apply?
要克制。Tailwind 团队的指导意见:把重复模式提取为框架组件(比如 React 的 Button),而不是 @apply 类——组件让标记、逻辑和样式聚合在一起,而 @apply 会重新制造工具类 CSS 本来要避免的命名和缓存失效问题。正当用途:给无法编辑的第三方标记设置样式(渲染后的 markdown、CMS 输出),以及共享焦点环这类小型全局基元。v4 中,独立文件里的 @apply 需要 '@reference "../app.css"' 才能读到主题。如果一个类名字符串重复三次以上,优先考虑组件或 cva() 变体映射。

Previews

Example previews and starter templates

Use these templates as Tailwind CSS prompt references by naming components, layout classes, breakpoints, states, and design tokens together.

Shadcn Analytics

A strong base for Tailwind + shadcn/ui dashboards, cards, filters, and KPI-heavy layouts.

Open template

Documentation Site

Useful for developer docs, sidebar navigation, content hierarchy, and utility-first content layouts.

Open template

SaaS Landing Page

Helpful for Tailwind marketing pages with clean section rhythm, CTA hierarchy, and responsive spacing.

Open template

File Manager App

A practical app-shell reference for tables, list-detail panels, toolbars, and denser Tailwind patterns.

Open template

想要完整的设计系统?

StyleKit 提供 148 种视觉风格,每种都有 design tokens、组件配方和可导出的 AI Rules。

相关提示词库

探索 StyleKit 的其他 AI 提示词库,覆盖不同界面类型与技术栈。