);
}
```
## Date Filtering Pattern
```tsx
import { useState } from 'react';
import { Calendar } from '@/components/ui/calendar';
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
import { Button } from '@/components/ui/button';
import { CalendarIcon } from 'lucide-react';
import { format } from 'date-fns';
export function DateRangePicker() {
const [date, setDate] = useState();
return (
);
}
```
## Performance Considerations
### Large Datasets
For tables with 1000+ rows:
```tsx
import { useVirtualizer } from '@tanstack/react-virtual';
// Implement virtual scrolling for performance
```
### Real-time Updates
```tsx
import { useQuery } from '@tanstack/react-query';
// Poll for updates
const { data } = useQuery({
queryKey: ['metrics'],
queryFn: fetchMetrics,
refetchInterval: 30000, // 30 seconds
});
```
### Optimize Charts
- Limit data points (aggregate if > 100 points)
- Debounce resize events
- Use memo for expensive calculations
## Responsive Design
**Mobile Dashboard** (< 768px):
- Stack cards vertically
- Hide sidebar, use hamburger menu
- Simplify charts (fewer data points)
- Prioritize key metrics above fold
**Tablet** (768px - 1024px):
- 2-column grid for metrics
- Sidebar can collapse/expand
- Full chart functionality
**Desktop** (> 1024px):
- 4-column grid for metrics
- Permanent sidebar
- Full feature set
## Accessibility
- Use semantic HTML (`
`, `
`, `
`)
- Provide chart descriptions with `aria-label`
- Ensure color contrast meets WCAG AA
- Keyboard navigation for all interactive elements
- Screen reader announcements for data updates
## Next Steps
1. Define your metrics and data sources
2. Set up data fetching with TanStack Query
3. Build reusable chart components
4. Implement filtering and date range selection
5. Add real-time updates if needed
6. Test with realistic data volumes
7. Optimize for performance