ui-builder

安装量: 54
排名: #13638

安装

npx skills add https://github.com/eddiebe147/claude-settings --skill ui-builder

UI/UX Builder Skill Overview

This skill helps you build beautiful, accessible, and responsive user interfaces using modern React patterns, Tailwind CSS, and component libraries like Shadcn/ui.

Core Principles 1. Mobile-First Design Start with mobile layout Use responsive breakpoints: sm (640px), md (768px), lg (1024px), xl (1280px) Test on multiple screen sizes 2. Accessibility Use semantic HTML Add ARIA labels where needed Ensure keyboard navigation works Maintain color contrast ratios Support screen readers 3. Performance Lazy load heavy components Optimize images Use CSS animations over JS when possible Minimize re-renders 4. Consistency Use design tokens (colors, spacing, typography) Follow established patterns Maintain visual hierarchy Tailwind CSS Patterns Layout // Flex layouts

Left
Right

// Grid layouts

Card 1
Card 2
Card 3

// Container

Content

// Centering

Centered

Responsive Design // Mobile first

Responsive text

// Hide/show by breakpoint

Desktop only
Mobile only

// Responsive padding/margin

Responsive padding

Colors & Themes // Background colors

Content

// Text colors

Text

// Hover states

// Focus states

Spacing // Margin/Padding scale: 0, 1(4px), 2(8px), 4(16px), 6(24px), 8(32px), 12(48px), 16(64px)

Padding 16px
Margin top 32px, bottom 16px
Vertical spacing between children
Gap between flex/grid items

Common Component Patterns Button // components/ui/button.tsx import { cn } from '@/lib/utils'

interface ButtonProps extends React.ButtonHTMLAttributes { variant?: 'default' | 'outline' | 'ghost' | 'destructive' size?: 'sm' | 'md' | 'lg' }

export function Button({ className, variant = 'default', size = 'md', ...props }: ButtonProps) { return ( ) }

Form // components/forms/contact-form.tsx 'use client' import { useState } from 'react' import { Input } from '@/components/ui/input' import { Button } from '@/components/ui/button'

export function ContactForm() { const [loading, setLoading] = useState(false) const [errors, setErrors] = useState>({})

async function handleSubmit(e: React.FormEvent) { e.preventDefault() setLoading(true) setErrors({})

const formData = new FormData(e.currentTarget)
const email = formData.get('email') as string
const message = formData.get('message') as string

// Validation
const newErrors: Record<string, string> = {}
if (!email) newErrors.email = 'Email is required'
if (!message) newErrors.message = 'Message is required'

if (Object.keys(newErrors).length > 0) {
  setErrors(newErrors)
  setLoading(false)
  return
}

try {
  const response = await fetch('/api/contact', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ email, message }),
  })

  if (!response.ok) throw new Error('Failed to send')

  // Success
  e.currentTarget.reset()
  alert('Message sent!')
} catch (error) {
  setErrors({ submit: 'Failed to send message' })
} finally {
  setLoading(false)
}

}

return (

{errors.email && (

{errors.email}

)}

  <div>
    <label htmlFor="message" className="block text-sm font-medium mb-1">
      Message
    </label>
    <textarea
      id="message"
      name="message"
      rows={4}
      className="w-full rounded-md border border-gray-300 px-3 py-2"
      placeholder="Your message..."
    />
    {errors.message && (
      <p className="mt-1 text-sm text-red-600">{errors.message}</p>
    )}
  </div>

  {errors.submit && (
    <p className="text-sm text-red-600">{errors.submit}</p>
  )}

  <Button type="submit" disabled={loading}>
    {loading ? 'Sending...' : 'Send Message'}
  </Button>
</form>

) }

Animations Tailwind Transitions // Hover effects

Hover to scale

// Opacity fade

Fade in

// Transform

Slide on hover

Framer Motion 'use client' import { motion } from 'framer-motion'

// Fade in <motion.div initial={{ opacity: 0 }} animate={{ opacity: 1 }} transition={{ duration: 0.5 }}

Fades in

// Slide in <motion.div initial={{ x: -100, opacity: 0 }} animate={{ x: 0, opacity: 1 }} transition={{ duration: 0.5 }}

Slides in

// Stagger children <motion.div initial="hidden" animate="visible" variants={{ visible: { transition: { staggerChildren: 0.1 } } }}

{items.map(item => ( <motion.div key={item.id} variants={{ hidden: { opacity: 0, y: 20 }, visible: { opacity: 1, y: 0 } }}

  {item.title}
</motion.div>

))}

Icons Lucide React import { Search, User, Settings, ChevronRight } from 'lucide-react'

// Basic usage

// With color

// In button

Loading States Skeleton export function Skeleton({ className }: { className?: string }) { return (

) }

// Usage

Spinner export function Spinner({ className }: { className?: string }) { return (

) }

Dark Mode Setup // app/providers.tsx 'use client' import { ThemeProvider } from 'next-themes'

export function Providers({ children }: { children: React.ReactNode }) { return ( {children} ) }

// app/layout.tsx export default function RootLayout({ children }: { children: React.ReactNode }) { return ( {children} ) }

Theme Toggle 'use client' import { useTheme } from 'next-themes' import { Moon, Sun } from 'lucide-react'

export function ThemeToggle() { const { theme, setTheme } = useTheme()

return ( ) }

Dark Mode Styles // Tailwind dark mode

Dark mode aware

// tailwind.config.js module.exports = { darkMode: 'class', theme: { extend: { colors: { background: 'hsl(var(--background))', foreground: 'hsl(var(--foreground))', } } } }

Best Practices Accessibility Checklist Use semantic HTML (header, nav, main, footer, article, section) Add alt text to images Ensure sufficient color contrast (4.5:1 for normal text) Support keyboard navigation (tab, enter, escape) Add ARIA labels where needed Use focus-visible for keyboard focus Test with screen reader Performance Checklist Use next/image for images Lazy load components not in viewport Minimize client-side JavaScript Use CSS animations over JS Implement loading skeletons Optimize font loading Use proper image formats (WebP, AVIF) Responsive Design Checklist Design mobile-first Test on multiple screen sizes Use responsive images Implement touch-friendly tap targets (44x44px minimum) Test landscape and portrait Handle safe areas on mobile Consider foldable devices Utility Function // lib/utils.ts import { clsx, type ClassValue } from 'clsx' import { twMerge } from 'tailwind-merge'

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

Common Layouts Dashboard Layout export default function DashboardLayout({ children }: { children: React.ReactNode }) { return (

{/ Sidebar /}

  {/* Main content */}
  <div className="flex-1 overflow-auto">
    <header className="border-b bg-white px-6 py-4">
      Header
    </header>
    <main className="p-6">{children}</main>
  </div>
</div>

) }

Landing Page Hero export function Hero() { return (

Your Amazing Product

A compelling description that explains what your product does

) }

When to Use This Skill

Invoke this skill when:

Building new UI components Creating layouts and page structures Implementing responsive design Adding animations and transitions Working with forms and inputs Implementing dark mode Ensuring accessibility Optimizing UI performance Creating loading states Building navigation components

返回排行榜