# responsive ## When to Use Use this command when you want to: - Implement responsive/mobile design using DaisyUI components - Make existing components mobile-friendly with DaisyUI patterns - Create beautiful, modern responsive layouts following DaisyUI documentation - Optimize UI for different screen sizes using DaisyUI's responsive features ## Prerequisites - Component or page file open or specified - Tailwind CSS configured - DaisyUI installed and configured - Reference to DaisyUI documentation: https://daisyui.com/components/ - Understanding of the component's current structure ## Execution Steps ### Step 1: Analyze Current Component Read the component file to understand its structure: **If file is open in editor:** - Use the currently open file **If file path provided:** - Read the file: `cat [file-path]` **Analyze:** - Current layout structure (grid, flex, etc.) - Existing responsive classes (if any) - Component complexity and nesting - Content that needs to be responsive (tables, forms, charts, cards) ### Step 2: Identify Responsive Requirements Determine what needs to be responsive: **Common responsive patterns:** - **Navigation**: Mobile hamburger menu, desktop horizontal nav - **Tables**: Horizontal scroll on mobile, full table on desktop - **Forms**: Stacked inputs on mobile, side-by-side on desktop - **Cards/Grids**: Single column on mobile, multi-column on desktop - **Charts**: Smaller on mobile, larger on desktop - **Modals**: Full screen on mobile, centered on desktop - **Text**: Smaller on mobile, larger on desktop - **Spacing**: Tighter on mobile, more spacious on desktop **Identify:** - Which elements need responsive behavior - Breakpoints where layout should change - Mobile vs desktop content differences ### Step 3: Apply Mobile-First Responsive Design Implement responsive design using Tailwind's mobile-first approach: #### 3.1: Breakpoint Strategy **Tailwind breakpoints (mobile-first):** - Base (default): Mobile (< 640px) - `sm:` - Small devices (≥ 640px) - `md:` - Medium devices (≥ 768px) - `lg:` - Large devices (≥ 1024px) - `xl:` - Extra large (≥ 1280px) - `2xl:` - 2X Extra large (≥ 1536px) **Pattern:** Start with mobile styles, then add larger breakpoints: ```tsx // Mobile first: base styles are for mobile
// Mobile: full width, padding 4 // md+: padding 6 // lg+: padding 8
``` #### 3.2: Layout Patterns **Grid Layouts:** ```tsx // Single column mobile, multi-column desktop
{/* Cards */}
// Responsive grid with auto-fit
``` **Flexbox Layouts:** ```tsx // Stack on mobile, row on desktop
{/* Items */}
// Center on mobile, space-between on desktop
``` **Container Patterns:** ```tsx // Use layout utility class or custom container
{/* Content with responsive margins */}
// Or custom responsive container
``` #### 3.3: Navigation Patterns (DaisyUI Navbar) **DaisyUI Navbar Pattern** (https://daisyui.com/components/navbar/): ```tsx // DaisyUI navbar with responsive menu
{/* Mobile menu button */}
Logo
{/* Desktop navigation */}
{/* Navbar end */}
// Mobile drawer/sidebar (DaisyUI Drawer pattern)
    {/* Mobile menu items */}
``` #### 3.4: Table Patterns (DaisyUI Table) **DaisyUI Table Patterns** (https://daisyui.com/components/table/): ```tsx // Option 1: Horizontal scroll on mobile (recommended)
{/* Table rows */}
Header 1 Header 2
// Option 2: Responsive table size (mobile: table-xs, desktop: table)
{/* Table content */}
// Option 3: Card layout on mobile, table on desktop
{/* DaisyUI cards for mobile */}
{/* Card content matching table data */}
{/* Table for desktop */}
``` #### 3.5: Form Patterns (DaisyUI Form) **DaisyUI Form Patterns** (https://daisyui.com/components/form/): ```tsx // DaisyUI form-control with responsive grid
{/* Stacked on mobile, side-by-side on desktop */}
{/* Full width field */}
{/* Responsive button */}
``` #### 3.6: Typography Patterns **Responsive Text:** ```tsx // Smaller on mobile, larger on desktop

Title

Content

``` #### 3.7: Spacing Patterns **Responsive Spacing:** ```tsx // Tighter on mobile, more spacious on desktop
{/* Content */}
// Responsive gaps
{/* Items */}
``` #### 3.8: Modal/Dialog Patterns (DaisyUI Modal) **DaisyUI Modal Patterns** (https://daisyui.com/components/modal/): ```tsx // Full screen on mobile, centered on desktop

Modal Title

Modal content

// Responsive modal with different sizes
{/* Modal content */}
``` #### 3.9: Chart/Visualization Patterns **Responsive Charts:** ```tsx // Responsive chart container
// Or use aspect ratio
``` ### Step 4: Reference DaisyUI Documentation **Before implementing any component, check DaisyUI documentation:** - Open or reference: https://daisyui.com/components/ - Find the component you need (navbar, card, table, modal, etc.) - Review the component's responsive examples and classes - Use the exact DaisyUI classes and patterns from the docs **DaisyUI Documentation Structure:** - Each component page shows examples - Copy the exact class names and structure - Adapt the examples to your use case with responsive breakpoints ### Step 5: Apply DaisyUI Responsive Components Use DaisyUI components following official documentation: https://daisyui.com/components/ **DaisyUI Responsive Components (from docs):** 1. **Navbar** (https://daisyui.com/components/navbar/): - Use `navbar` with `navbar-start`, `navbar-center`, `navbar-end` - Mobile hamburger: `btn btn-ghost lg:hidden` - Desktop nav: `hidden lg:flex` ```tsx
{/* Desktop nav items */}
``` 2. **Drawer** (https://daisyui.com/components/drawer/): - Use `drawer` with `drawer-side` for mobile sidebar - Toggle with `drawer-open` class ```tsx
    {/* Sidebar content */}
``` 3. **Card** (https://daisyui.com/components/card/): - Use `card` with `card-body` for responsive cards - Responsive grid: `grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3` ```tsx

Title

Content

``` 4. **Table** (https://daisyui.com/components/table/): - Wrap in `overflow-x-auto` for mobile scroll - Use `table-xs` for mobile, `table` for desktop ```tsx
{/* Table content */}
``` 5. **Modal** (https://daisyui.com/components/modal/): - Use `modal` with `modal-box` for responsive modals - Full screen mobile: `w-full max-w-none md:max-w-2xl` ```tsx
{/* Modal content */}
``` 6. **Form** (https://daisyui.com/components/form/): - Use `form-control` with responsive grid - Inputs: `input input-bordered w-full` ```tsx
``` 7. **Bottom Navigation** (https://daisyui.com/components/bottom-navigation/): - Use `btm-nav` for mobile bottom navigation ```tsx
``` 8. **Tabs** (https://daisyui.com/components/tabs/): - Use `tabs` with responsive layout - Mobile: `tabs tabs-boxed`, Desktop: `tabs tabs-lifted` ```tsx
Tab 1 Tab 2
``` 9. **Dropdown** (https://daisyui.com/components/dropdown/): - Use `dropdown` with responsive positioning ```tsx
    {/* Dropdown items */}
``` 10. **Stats** (https://daisyui.com/components/stats/): - Use `stats` with responsive grid ```tsx
...
``` ### Step 6: Implement Beautiful Mobile UX **Mobile UX Best Practices:** 1. **Touch Targets:** - Minimum 44x44px touch targets - Adequate spacing between interactive elements ```tsx ``` 2. **Swipe Gestures:** - Consider swipeable cards/carousels - Use libraries like `react-swipeable` if needed 3. **Bottom Navigation** (DaisyUI Bottom Nav - https://daisyui.com/components/bottom-navigation/): - Use DaisyUI `btm-nav` for mobile bottom navigation ```tsx
``` 4. **Sticky Headers:** - Keep important actions accessible ```tsx
{/* Header content */}
``` 5. **Loading States** (DaisyUI Loading - https://daisyui.com/components/loading/): - Use DaisyUI loading spinners appropriately sized for mobile ```tsx
// Or use loading text
Loading...
``` ### Step 7: Test Responsive Breakpoints Verify the implementation works at different breakpoints: **Test breakpoints:** - Mobile: 375px, 414px (iPhone sizes) - Tablet: 768px, 1024px (iPad sizes) - Desktop: 1280px, 1536px+ **Check:** - Layout doesn't break at any breakpoint - Text is readable at all sizes - Interactive elements are easily tappable - Content doesn't overflow horizontally - Images scale appropriately ### Step 8: Optimize Performance **Mobile Performance:** 1. **Lazy Loading:** - Lazy load images and heavy components ```tsx ... ``` 2. **Conditional Rendering:** - Render mobile/desktop versions conditionally if needed ```tsx {isMobile ? : } ``` 3. **Reduce Animations on Mobile:** - Consider `prefers-reduced-motion` ```tsx
``` ## Error Handling **If component file not found:** - Check file path - Verify file exists - **STOP**: Cannot proceed without component **If Tailwind classes not working:** - Verify Tailwind config includes the file - Check if classes are in content paths - Rebuild Tailwind: `npm run build` or check build process **If layout breaks at breakpoints:** - Check for conflicting classes - Verify breakpoint order (mobile-first) - Test with browser dev tools - Fix overflow issues with `overflow-x-hidden` on body **If DaisyUI components not responsive:** - Check DaisyUI version: `npm list daisyui` - Verify Tailwind config includes DaisyUI plugin - Reference DaisyUI docs: https://daisyui.com/components/ - Use DaisyUI's responsive utilities from documentation - Ensure you're using the correct DaisyUI class names ## Example Execution **User input:** `/responsive` (with component file open) **AI execution:** 1. Analyze component: Read `UnifiedTradingModal.tsx` - Found: Large form with multiple sections - Found: Tables and cards - Found: Some responsive classes already present 2. Identify requirements: - Form inputs need stacking on mobile - Tables need horizontal scroll - Modal needs full-screen on mobile - Cards need single column on mobile 3. Reference DaisyUI docs: - Check https://daisyui.com/components/modal/ for modal patterns - Check https://daisyui.com/components/form/ for form patterns - Check https://daisyui.com/components/table/ for table patterns - Check https://daisyui.com/components/card/ for card patterns 4. Implement responsive using DaisyUI: - Update form: Use `form-control` with `grid grid-cols-1 md:grid-cols-2 gap-4` - Update tables: Wrap in `overflow-x-auto` with `table table-zebra` - Update modal: Use DaisyUI `modal` with `modal-box w-full max-w-none md:max-w-2xl` - Update cards: Use DaisyUI `card` with `grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3` 5. Apply mobile UX: - Use DaisyUI buttons (already meet 44px touch target) - Add responsive spacing: `p-4 md:p-6` - Update typography: `text-sm md:text-base` 6. Test: Verify at 375px, 768px, 1024px breakpoints 7. Success: "✅ Component is now fully responsive using DaisyUI components!" **If table component:** 1. Analyze: Read table component 2. Identify: Table needs mobile-friendly layout 3. Implement: - Option 1: Horizontal scroll wrapper - Option 2: Card layout for mobile, table for desktop 4. Choose best approach based on data complexity 5. Implement chosen pattern 6. Success: "✅ Table is now responsive with [chosen pattern]!" ## Important Notes - ✅ **Mobile-first approach** - Base styles for mobile, then add larger breakpoints - ✅ **Use Tailwind breakpoints** - sm: 640px, md: 768px, lg: 1024px, xl: 1280px, 2xl: 1536px - ✅ **DaisyUI components** - Always use DaisyUI components from https://daisyui.com/components/ - ✅ **Follow DaisyUI docs** - Reference official documentation for component usage - ✅ **Touch targets** - Minimum 44x44px for mobile (DaisyUI buttons meet this) - ✅ **No horizontal scroll** - Prevent horizontal overflow on mobile - ✅ **Test all breakpoints** - Verify at 375px, 768px, 1024px, 1280px - ✅ **Performance** - Lazy load images, optimize for mobile - ⚠️ **Breakpoint order** - Always mobile-first: base → sm → md → lg → xl → 2xl - ⚠️ **Content priority** - Show most important content first on mobile - ⚠️ **Spacing** - Tighter on mobile, more spacious on desktop - ⚠️ **DaisyUI classes** - Use DaisyUI utility classes (`btn`, `card`, `input`, etc.) - 📱 **Mobile breakpoints**: < 640px (base), ≥ 640px (sm), ≥ 768px (md) - 💻 **Desktop breakpoints**: ≥ 1024px (lg), ≥ 1280px (xl), ≥ 1536px (2xl) - 🎨 **DaisyUI Components**: `navbar`, `drawer`, `card`, `table`, `modal`, `form`, `btm-nav`, `tabs`, `dropdown`, `stats` - 📚 **DaisyUI Docs**: https://daisyui.com/components/ - Always reference for component patterns - 🔧 **Layout utility**: Use `.layout` class or custom responsive containers