AgentSkillsCN

ui-design

为构建更好的界面而设定的有主张的约束。当构建UI组件、实现动画、设计布局、审查前端可访问性,或使用Tailwind CSS、动效/react或可访问基元如Radix/Base UI时使用。

SKILL.md
--- frontmatter
name: ui-design
description: Opinionated constraints for building better interfaces with agents. Use when building UI components, implementing animations, designing layouts, reviewing frontend accessibility, or working with Tailwind CSS, motion/react, or accessible primitives like Radix/Base UI.

UI Design

Opinionated constraints for building better interfaces with agents.

When to Use

  • Building UI components with Tailwind CSS
  • Implementing animations or transitions
  • Adding interactive elements with keyboard/focus behavior
  • Reviewing frontend code for accessibility
  • Designing layouts with proper z-index and spacing
  • Working with loading states, error handling, or empty states

Stack

RequirementRule
Tailwind CSSMUST use defaults (spacing, radius, shadows) before custom values
Animation libraryMUST use motion/react (formerly framer-motion) for JS animation
CSS animationSHOULD use tw-animate-css for entrance and micro-animations
Class logicMUST use cn utility (clsx + tailwind-merge)

Components

RequirementRule
Interactive primitivesMUST use accessible primitives (Base UI, React Aria, Radix) for keyboard/focus behavior
Existing componentsMUST use project's existing primitives first
ConsistencyNEVER mix primitive systems within the same interaction surface
New primitivesSHOULD prefer Base UI if compatible with stack
Icon buttonsMUST add aria-label to icon-only buttons
Custom behaviorNEVER rebuild keyboard or focus behavior by hand unless explicitly requested

Interaction

RequirementRule
Destructive actionsMUST use AlertDialog for destructive or irreversible actions
Loading statesSHOULD use structural skeletons
Viewport heightNEVER use h-screen, use h-dvh
Fixed elementsMUST respect safe-area-inset
Error displayMUST show errors next to where the action happens
Input behaviorNEVER block paste in input or textarea elements

Animation

RequirementRule
DefaultNEVER add animation unless explicitly requested
Compositor propsMUST animate only transform, opacity
Layout propsNEVER animate width, height, top, left, margin, padding
Paint propsSHOULD avoid background, color except for small, local UI (text, icons)
Entrance easingSHOULD use ease-out on entrance
Feedback timingNEVER exceed 200ms for interaction feedback
LoopingMUST pause looping animations when off-screen
AccessibilityMUST respect prefers-reduced-motion
Custom easingNEVER introduce custom easing curves unless explicitly requested
Large surfacesSHOULD avoid animating large images or full-screen surfaces

Typography

RequirementRule
HeadingsMUST use text-balance
Body textMUST use text-pretty for paragraphs
DataMUST use tabular-nums
Dense UISHOULD use truncate or line-clamp
Letter spacingNEVER modify letter-spacing (tracking-) unless explicitly requested

Layout

RequirementRule
Z-indexMUST use a fixed scale (no arbitrary z-x)
Square elementsSHOULD use size-x instead of w-x + h-x

Performance

RequirementRule
Blur effectsNEVER animate large blur() or backdrop-filter surfaces
Will-changeNEVER apply will-change outside an active animation
useEffectNEVER use for anything expressible as render logic

Design

RequirementRule
GradientsNEVER use unless explicitly requested
Purple/multicolor gradientsNEVER use
Glow effectsNEVER use as primary affordances
ShadowsSHOULD use Tailwind CSS default scale unless explicitly requested
Empty statesMUST give one clear next action
Accent colorsSHOULD limit to one per view
Color tokensSHOULD use existing theme or Tailwind CSS tokens before introducing new ones

Quick Reference

Allowed Animation Properties

code
transform, opacity

Forbidden Animation Properties

code
width, height, top, left, margin, padding, blur(), backdrop-filter

Required Accessibility Patterns

tsx
// Icon button - always add aria-label
<button aria-label="Close dialog">
  <XIcon />
</button>

// Respect reduced motion
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; }
}

Class Utility Pattern

tsx
import { clsx } from 'clsx';
import { twMerge } from 'tailwind-merge';

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