Cursor prompt
Cursor: Implement Infinite Scroll
Cursor-based pagination with IntersectionObserver, loading states, error recovery, and scroll position restoration.
Implement infinite scroll for the {{entity}} list in {{project_name}}. ## API Endpoint: {{api_endpoint}} ## Items per page: {{page_size}} ### Cursor-Based Pagination (preferred over offset) API returns: { data: T[], nextCursor: string | null, hasMore: boolean } Query pattern: WHERE id > $cursor ORDER BY id ASC LIMIT $limit Prevents duplicate/skipped items when new records are added while scrolling. ### usePaginatedList Hook ```typescript const { items, isLoading, isFetchingMore, hasMore, error, loadMore } = usePaginatedList<{{entity_type}}>(endpoint, pageSize); ``` - Accumulates all pages into a single items array - Uses SWR Infinite or React Query Infinite for caching and deduplication - Exposes loadMore() for manual trigger (also called by IntersectionObserver) ### IntersectionObserver Trigger Place a sentinel div after the last list item. When sentinel enters the viewport: call loadMore() if hasMore && !isFetchingMore. Settings: threshold: 0.1, rootMargin: "0px 0px 200px 0px" (pre-load 200px early). ### Loading States - Initial load: skeleton cards matching real card dimensions - Loading more: small spinner centered below last item - Error: "Failed to load" with Retry button — preserve already-loaded items - End of list: subtle "That's everything" message ### Scroll Position Restoration On navigation away: save scrollY to sessionStorage with list identifier. On back-navigation: restore scroll position after items re-render. ### Output usePaginatedList hook, InfiniteList component, sentinel component, and API handler.
Fill in: {{entity}}, {{project_name}}, {{api_endpoint}}, {{page_size}}, {{entity_type}}. In Loopy you fill these in a form and copy the finished prompt in one click.
More ui design prompts
- ClaudeClaude: Convert Figma to CodeStructured prompt for converting Figma design specifications into pixel-perfect React components.
- CursorCursor: Add Dark Mode with CSS VariablesImplement theme switching with CSS custom properties, localStorage persistence, system preference detection, and flash-free loading.
- CursorCursor: Add WCAG Accessibility to UIWCAG 2.1 AA compliance: keyboard navigation, ARIA labels, focus management, color contrast, and screen reader support.
- CursorCursor: Build Multi-Step Form WizardMulti-step wizard with per-step validation, progress indicator, back/next navigation, and sessionStorage persistence.
- CursorCursor: Create Drag-and-Drop InterfaceSortable lists and kanban boards with dnd-kit, keyboard accessibility, touch support, and optimistic UI updates.
- v0v0: Analytics DashboardData visualization dashboard with KPI cards, charts, data table, and date range filtering.

