Skip to content
Search prompts, tools, agents…

Prompt library

8,156 AI prompts, ready to copy

Search every prompt on the site directly, not just the articles. Each one links back to its guide with examples and tips.

606 prompts · Clear

Category 1: Component Generation & UI Layouts

Coding & Tech
Act as a Senior React Developer. Write a responsive Navigation Bar component using React 18, TypeScript, and Tailwind CSS.
Requirements:
- Include desktop navigation links and a mobile hamburger menu.
- Use React `useState` to control mobile drawer visibility.
- Close the drawer on ESC key press and when clicking outside.
- Ensure proper ARIA attributes (`aria-expanded`, `aria-label`).
- Export explicit TypeScript interface for navigation items (`{ label: string; href: string; icon?: React.ReactNode }`).
- Provide pure, runnable code with no inline styles.

Category 8: Accessibility (a11y) & Design System Compliance

Coding & Tech
Write an accessible, reusable Design System `Button` component in React using TypeScript, Tailwind CSS, and `clsx` / `tailwind-merge`.
Requirements:
- Variants: `primary`, `secondary`, `outline`, `danger`, `ghost`.
- Sizes: `sm`, `md`, `lg`.
- States: `isLoading`, `isDisabled`.
- When `isLoading` is true, display accessible loading spinner, disable interactions, and set `aria-busy="true"`.

Category 1: Architecture, Setup & Middleware

Coding & Tech
Write a Next.js `middleware.ts` file that executes on the Edge Runtime. 

Requirements:
1. Protect `/dashboard/*` and `/admin/*` routes, redirecting unauthenticated users to `/login?callbackUrl=...`.
2. Allow public access to `/`, `/login`, `/register`, and `/api/webhooks/*`.
3. Add custom HTTP security headers (CSP, X-Frame-Options, Referrer-Policy) to all outgoing responses.
4. Export an optimized `config` matcher object to prevent middleware from executing on static assets or image requests.

Category 1: Component Generation & UI Layouts

Coding & Tech
Create a reusable Modal Dialog component in React using TypeScript and Tailwind CSS.
Requirements:
- Props: `isOpen` (boolean), `onClose` () => void, `title` (string), `children` (React.ReactNode).
- Trap focus within the modal when open using pure React refs (or focus-trap pattern).
- Prevent background page scrolling when modal is open.
- Handle Keyboard events: 'Escape' key must trigger `onClose`.
- Include smooth transition backdrop animations.

Category 1: Component Generation & UI Layouts

Coding & Tech
Write a functional React component in TypeScript that implements an infinite scroll list using the Intersection Observer API.
Requirements:
- Do not use external libraries for scrolling.
- Fetch paginated mock data asynchronously when the sentinel element enters the viewport.
- Include explicit visual loading indicators, end-of-list indicator, and error recovery buttons.
- Handle cleanup for the Intersection Observer properly inside `useEffect`.

Category 1: Component Generation & UI Layouts

Coding & Tech
Act as a React Lead. Build a 3-step User Onboarding Form component using React 18, TypeScript, and React Hook Form with Zod validation schema.
Requirements:
- Step 1: Account Info (Email, Password).
- Step 2: Profile Details (Full Name, Avatar URL).
- Step 3: Confirmation and Summary.
- Allow users to move back and forth without losing step data.
- Validate inputs per step before allowing navigation to the next step.

Category 1: Component Generation & UI Layouts

Coding & Tech
Write a generic Data Table component in React with TypeScript (`TableProps<T>`).
Requirements:
- Accept `data: T[]` and dynamic `columns` config array containing `header`, `accessorKey`, and optional `sortable` flag.
- Provide client-side column sorting (ascending/descending toggle).
- Include a global text search input that filters rows across all visible text fields.
- Style cleanly using Tailwind CSS with alternating row colors.

Category 2: State Management & Custom Hooks

Coding & Tech
Write a custom React hook named `useLocalStorage<T>` in TypeScript.
Requirements:
- Sync state value with `window.localStorage`.
- Handle JSON serialization and deserialization safely with try/catch blocks.
- Listen to window 'storage' events so changes in one browser tab update the hook state in other open tabs.
- Provide initial value fallback support.

Category 2: State Management & Custom Hooks

Coding & Tech
Create a global e-commerce shopping cart store using Zustand and TypeScript.
Requirements:
- Cart Item state: `id`, `title`, `price`, `quantity`, `image`.
- Actions: `addItem`, `removeItem`, `updateQuantity`, `clearCart`.
- Derived selectors: `totalItemsCount` and `totalCartPrice`.
- Persist cart state to localStorage automatically using Zustand middleware.

Category 2: State Management & Custom Hooks

Coding & Tech
Write a robust `useFetch<T>` custom React hook in TypeScript.
Requirements:
- States: `data: T | null`, `isLoading: boolean`, `error: Error | null`, and `refetch: () => void`.
- Automatically instantiate `AbortController` to cancel pending HTTP requests when the component unmounts or URL changes.
- Handle HTTP non-200 responses cleanly by throwing formatted errors.

Category 3: TypeScript Integration & Type Safety

Coding & Tech
Act as a Senior TypeScript Developer. Refactor the following JavaScript React component to strict, error-free TypeScript code.
Requirements:
- Define explicit interfaces for all Props, State, and Event Handlers.
- Do not use `any` or `unknown` types unless strictly necessary with type guards.
- Correctly type DOM events (`React.ChangeEvent<HTMLInputElement>`, `React.FormEvent`, etc.).

[INSERT JAVASCRIPT COMPONENT CODE HERE]

Category 4: Performance Optimization

Coding & Tech
Act as a React Performance Engineer. Analyze the provided React component for performance bottlenecks and unnecessary re-renders.
Requirements:
- Identify objects/functions instantiated inside renders that break child component memoization.
- Apply `React.memo`, `useMemo`, and `useCallback` strategically where appropriate.
- Explain precisely WHY each optimization was applied.

[INSERT COMPONENT CODE HERE]

Category 5: Unit & Integration Testing

Coding & Tech
Act as a React QA Automation Architect. Write unit tests using Vitest and React Testing Library (`@testing-library/react`) for the following Form component.
Requirements:
- Test user typing into input fields.
- Test client-side validation error messages on empty submit.
- Test successful form submission and mock function call verification.
- Use `@testing-library/user-event` instead of `fireEvent`.

[INSERT COMPONENT CODE HERE]