frontend design
3
总安装量
0
周安装量
#55673
全站排名
安装命令
npx skills add https://github.com/xmenq/template-agentic-coding --skill 'Frontend Design'
Skill 文档
Frontend Design Skill
When to use this skill
Use when building or modifying any user-facing interface: pages, components, layouts, forms, navigation, modals, or visual design.
Design Principles
1. Mobile-first, responsive always
- Design for the smallest screen first, enhance for larger screens
- Use responsive breakpoints consistently:
sm: 640px |md: 768px |lg: 1024px |xl: 1280px
- Test every UI change at all breakpoints before submitting
2. Visual hierarchy matters
- Use size, weight, color, and spacing to guide the user’s eye
- Primary actions should be the most visually prominent
- Limit color palette to 2-3 primary colors + neutrals
- Use whitespace generously â don’t crowd elements
3. Consistency over creativity
- Reuse existing components before creating new ones
- Follow the established design tokens (colors, spacing, typography)
- Match existing interaction patterns (how buttons, forms, modals work)
4. Accessibility is not optional
- All interactive elements must be keyboard navigable
- Images need
alttext, icons needaria-label - Color contrast ratio: minimum 4.5:1 for normal text, 3:1 for large text
- Form inputs need associated labels
- Test with screen reader if possible
Component Architecture
Structure
ui/
âââ components/ # Reusable UI components
â âââ Button/
â â âââ Button.[ext]
â â âââ Button.styles.[ext]
â â âââ Button.test.[ext]
â âââ ...
âââ layouts/ # Page layout templates
âââ pages/ # Full page components
âââ hooks/ # UI-specific hooks/utilities
Component rules
- One component per file â no bundling unrelated components
- Co-locate styles â styles live next to their component
- Co-locate tests â test files next to what they test
- Props are the contract â type all props explicitly
- No business logic in components â components render, services compute
Component checklist
For every new component:
- Props are typed with clear names
- Has sensible defaults for optional props
- Handles loading, empty, and error states
- Responsive at all breakpoints
- Keyboard accessible
- Tested with at least 3 cases (default, edge, error)
Layout Patterns
Common layouts
| Pattern | When to use |
|---|---|
| Single column | Simple content pages, forms, articles |
| Sidebar + content | Dashboards, settings, admin panels |
| Grid | Card listings, galleries, product catalogs |
| Split screen | Comparison views, editor + preview |
| Stacked header/content/footer | Marketing pages, landing pages |
Spacing system
Use a consistent spacing scale (multiples of a base unit):
4px â 8px â 12px â 16px â 24px â 32px â 48px â 64px â 96px
Forms
Rules
- Every input has a visible label (not just placeholder text)
- Show validation errors inline, next to the relevant field
- Disable submit button while processing (with loading indicator)
- Preserve user input on validation failure (don’t clear the form)
- Use appropriate input types:
email,tel,number,date, etc.
Validation UX
- Validate on blur (when user leaves the field)
- Re-validate on change after first error
- Show success state (green check) after correction
- Summarize errors at the top if there are multiple
Animations & Transitions
Rules
- Subtle > flashy â animations should feel natural, not distracting
- Fast â most transitions should be 150-300ms
- Purposeful â every animation should communicate something (appearing, moving, feedback)
- Respect user preferences â honor
prefers-reduced-motion
Common transitions
| Action | Animation | Duration |
|---|---|---|
| Page/section enter | Fade in + slight slide up | 200ms |
| Modal open | Fade in + scale from 95% | 200ms |
| Hover feedback | Color/shadow change | 150ms |
| Loading state | Skeleton shimmer or spinner | Continuous |
| Success feedback | Brief green flash or checkmark | 300ms |
| Error feedback | Brief red highlight + shake | 300ms |
Dark Mode
If the project supports dark mode:
- Use CSS custom properties (variables) for all colors
- Define a
lightanddarktheme set - Never hardcode colors â always reference tokens
- Test all components in both themes
- Respect
prefers-color-schemesystem setting
Performance
- Lazy load images and heavy components below the fold
- Optimize images â use WebP/AVIF, appropriate sizes, responsive srcset
- Minimize layout shifts â set explicit dimensions on images/videos
- Bundle size â monitor and limit JS/CSS bundle sizes
- Critical CSS â inline above-the-fold styles when possible
PR Checklist for UI Changes
- Looks correct at all breakpoints (mobile, tablet, desktop)
- Keyboard navigation works
- Loading, empty, and error states are handled
- Colors meet contrast requirements
- Animations respect
prefers-reduced-motion - No hardcoded colors/sizes (uses design tokens)
- Screenshot or video attached to PR
- Dark mode tested (if applicable)