Skip to content
Search prompts, tools, agents…

Prompt library

8,162 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.

8,162 prompts

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 1: Identifying & Unpacking Toxic Workplace Dynamics

Health & Lifestyle
Act as an empathetic executive coach and organizational psychologist. I am going to describe a recent interaction at work that left me feeling uneasy. Help me break down this scenario objectively. Identify any subtle red flags, passive-aggressive behavior, or gaslighting dynamics at play, and explain why this behavior impacts psychological safety. 

Here is the scenario: [Insert detailed interaction details]

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]