React Prompt Recipes Prompts

Prompts tailored for generating, refactoring, and optimizing React components and applications. This category has 15 ready-made React Prompt Recipes prompts for ChatGPT, Claude and Gemini. Each one comes with a copy-ready template, a worked example, best practices and the mistakes to avoid. Open a prompt to fill in its blanks, or paste it straight into your AI chat.

Want one tailored to you? Fill in a prompt template and copy it.

React Prompt Recipes

AI Prompt to Build a React Billing Dashboard Component Using Stripe's MCP Server

This prompt is for frontend developers who need to build a React billing dashboard component that shows a customer's live subscription, invo…

ROLE:
You are a senior React/TypeScript developer building a billing dashboard component for a SaaS product.

CONTEXT:
The component should display billing data for a customer, retrieved via Stripe's MCP server: [LIST_DATA_NEEDED_E.G._SUBSCRIPTION_PLAN_NEXT_CHARGE_DATE_PAYMENT_METHOD_RECENT_INVOICES]
Framework/styling: [REACT_VERSION_AND_STYLING_APPROACH_E.G._TAILWIND_CSS_MODULES]

CONSTRAINTS:
- Handle these billing states explicitly: [LIST_STATES_E.G._ACTIVE_PAST_DUE_CANCELED_PENDING_NO_PAYMENT_METHOD]
- Show a loading skeleton while data is being fetched, and a clear error state if the fetch fails
- Format currency and dates using the customer's actual locale/currency, not a hardcoded format
- Separate the data-fetching hook from the presentational component

OUTPUT FORMAT:
1. A short explanation of the component's structure (hook + presentational component)
2. The full TypeScript code, in a single fenced code block, with comments marking where each billing state is handled
3. A one-line note on any assumption you made about the data shape returned by the MCP server

Make this prompt yours

React Prompt Recipes

AI Prompt to Build a React Dark Mode Toggle with System Preference Detection

A React dark mode toggle prompt asks ChatGPT, Claude, or Gemini to generate a theme switching component that respects the user's OS level li…

Role: You are a senior React developer building a reusable UI component.

Context:
Framework/setup: [REACT VERSION, e.g. React 18 with Vite, Next.js App Router]
Styling approach: [CSS variables / Tailwind CSS dark class / CSS-in-JS library]
Component location/usage: [where the toggle will live, e.g. app header, settings page]

Task:
Build a dark mode toggle component with this exact behavior:
1. On first load, detect the user's OS preference via the `prefers-color-scheme` media query and use it as the initial theme, applied before the main content paints (no flash of the wrong theme).
2. If the user has previously made an explicit choice, that stored choice overrides the OS preference on future visits.
3. Persist the user's explicit choice in [STORAGE MECHANISM, e.g. localStorage].
4. Listen for theme changes made in other open tabs and update this tab's theme to match.
5. Expose the current theme and a toggle function via [CONTEXT/HOOK NAME, e.g. a useTheme hook] so other components can read and react to it.

Constraints:
- Use [STYLING APPROACH] to apply the theme, not inline style objects
- Include accessible labeling (aria-label or visible text) that reflects the current state
- Keep the component dependency-free unless [ALLOWED LIBRARIES] are specified

Output format:
Return the full component code in a fenced code block, followed by a short usage example showing how to wrap the app and consume the hook elsewhere.

Make this prompt yours

React Prompt Recipes

AI Prompt to Build a React Kanban Board With Drag-and-Drop

This prompt gives ChatGPT, Claude, or Gemini a complete specification for building a React Kanban board with drag and drop column reordering…

You are a senior React developer specializing in accessible, production-ready UI components.

Context:
- Framework: [REACT VERSION, e.g. React 18 with TypeScript]
- Drag-and-drop library: [LIBRARY NAME, e.g. @dnd-kit/core]
- Styling approach: [e.g. Tailwind CSS, CSS Modules, styled-components]
- Columns or workflow stages: [LIST OF COLUMN NAMES, e.g. Backlog, In Progress, Review, Done]
- State source: [e.g. local state, Zustand store, REST API endpoint]

Build a Kanban board component with the following requirements:
1. Render one column per workflow stage listed above, each showing its card count
2. Support dragging cards between columns and reordering cards within a column
3. Support keyboard-based reordering, not mouse-only interaction, for accessibility
4. Identify cards by a stable [ID FIELD NAME] field, never by array index
5. Call a [CALLBACK NAME] function on every successful move, passing the card id, source column, destination column, and new index
6. Show an optimistic UI update immediately, then roll back if [CALLBACK NAME] rejects
7. Handle empty columns and drops outside any valid column gracefully

Output format:
- The main board component
- Column and Card subcomponents
- Any custom hooks used for drag state
- A short usage example showing how to wire [CALLBACK NAME] to a real API call
- Brief notes on any library-specific setup required, such as providers, context, or CSS imports

Make this prompt yours

React Prompt Recipes

AI Prompt for an Accessible React Autocomplete Combobox

This prompt is for developers asking Claude , ChatGPT , or Gemini to generate a React autocomplete combobox component, the input plus dropdo…

Generate a React component with the following specification.

ROLE
- You are a frontend engineer who writes accessible, production-ready React components.

COMPONENT
- A searchable autocomplete combobox named [COMPONENT NAME].
- Props: options ([OPTION SHAPE, e.g. array of {id, label}]), value, onChange, placeholder.
- Controlled component: value and onChange are provided by the parent; do not manage selected value as internal-only state.

ACCESSIBILITY REQUIREMENTS
- Use the ARIA 1.2 combobox pattern: role="combobox" on the input, role="listbox" on the options container, role="option" on each item, and aria-activedescendant to track the highlighted option.
- Support keyboard interaction: ArrowDown/ArrowUp to move highlight, Enter to select the highlighted option, Escape to close the list, Home/End to jump to first/last option.
- Announce the number of matching results to screen readers when the list updates.

BEHAVIOR
- Filter options client-side, debounced by [DEBOUNCE MS, e.g. 150]ms.
- Close the dropdown on click outside or on Escape.
- If no options match, display [EMPTY STATE MESSAGE] inside the listbox instead of hiding it.

OUTPUT FORMAT
- A single functional component using hooks, written in [TYPESCRIPT OR JAVASCRIPT], with inline comments marking each accessibility feature.

Make this prompt yours

React Prompt Recipes

AI Prompt to Build a React Command Palette (Cmd+K) Component

This AI prompt generates a complete React command palette component, the kind of Cmd+K (or Ctrl+K) search and action overlay popularized by…

ROLE: You are a senior frontend engineer who writes accessible, reusable React components with TypeScript.

TASK: Build a command palette (Cmd+K / Ctrl+K) component for a React application with the following behavior:
1. A global keyboard shortcut ([SHORTCUT, E.G. CMD+K]) opens the palette from anywhere in the app.
2. The palette renders as a centered modal overlay with a search input focused automatically on open.
3. Below the input, show a filtered, scrollable list of commands based on a prop-driven array of {id, label, icon, action, group} items.
4. Support fuzzy or substring matching on the label as the user types, updating the list in real time.
5. Support arrow-up/arrow-down to move the active selection and Enter to run the selected command's action and close the palette.
6. Escape closes the palette and returns focus to whatever element triggered it.
7. Group commands by their 'group' field with a small header label per group in the results list.

CONSTRAINTS:
- Use React hooks only, no class components.
- Trap focus inside the palette while it is open.
- Use ARIA roles appropriate for a combobox/listbox pattern.
- Style with [STYLING APPROACH, E.G. TAILWIND CSS / CSS MODULES].

OUTPUT FORMAT: A single CommandPalette.tsx component file plus a short usage example showing how to pass the command list and mount the component, with brief inline comments explaining the keyboard and focus logic.

APP CONTEXT: [BRIEF DESCRIPTION OF THE APP AND EXAMPLE COMMANDS, E.G. 'PROJECT MANAGEMENT TOOL WITH COMMANDS LIKE NEW TASK, GO TO SETTINGS, INVITE TEAMMATE']

Make this prompt yours

React Prompt Recipes

AI Prompt to Build a React Infinite Scroll List With Virtualization

This prompt is for developers who need a React infinite scroll list that stays fast even with thousands of rows, by combining lazy loaded pa…

ROLE: You are a senior React developer who specializes in performant list rendering for data-heavy interfaces.

CONTEXT:
Framework: [REACT VERSION, e.g. React 18 with hooks]
Data source: [DESCRIBE THE API OR DATA SOURCE, e.g. a paginated REST endpoint returning 50 items per page]
List item shape: [DESCRIBE THE FIELDS EACH ROW NEEDS TO DISPLAY]
Expected list size: [APPROXIMATE TOTAL ROWS, e.g. up to 10,000]

TASK:
Build a React component that renders this list with infinite scroll and virtualization:
1. A custom hook that manages paginated fetching, tracks loading and error state, and triggers the next page fetch when the user nears the bottom of the list.
2. A virtualized list renderer that only mounts rows near the current viewport, using a windowing technique, with a small buffer of extra rows above and below the visible area.
3. Loading placeholders for in-flight pages and a clear end-of-list indicator when there is no more data.
4. Basic error handling that lets the user retry a failed page fetch.

CONSTRAINTS:
- Use functional components and hooks only
- Avoid unnecessary re-renders of rows that haven't changed
- Assume variable row heights unless told otherwise
- Include brief inline comments explaining the virtualization math

OUTPUT FORMAT:
1. A short explanation of the approach
2. The custom data-fetching hook as a complete code block
3. The virtualized list component as a complete code block
4. Notes on any assumptions made about row height or page size

Make this prompt yours

React Prompt Recipes

ChatGPT Prompt to Build a React Drag-and-Drop File Upload Component With Progress Bar

This React drag and drop file upload component prompt is built for developers who need a working uploader with a drop zone, file previews, a…

ROLE
You are a senior front-end engineer who specializes in React component architecture and accessible UI.

CONTEXT
I'm building a [FORM / DASHBOARD / ADMIN PANEL] in React using [REACT VERSION, e.g. React 18 with function components] and [STYLING APPROACH, e.g. Tailwind CSS / CSS Modules / styled-components]. I need a file upload component that supports drag-and-drop in addition to a standard click-to-browse input.

REQUIREMENTS
- Accept these file types: [ALLOWED FILE TYPES, e.g. .png, .jpg, .pdf]
- Enforce a max file size of [MAX FILE SIZE] and a max file count of [MAX FILE COUNT]
- Show a visually distinct drop zone state when a file is dragged over it
- Display a progress bar per file while it uploads, using [UPLOAD METHOD, e.g. an onUploadProgress callback from axios, or XMLHttpRequest progress events]
- Show clear success and error states per file, including a retry option on failure
- Accept the actual upload function as a prop so the component is backend-agnostic
- Be keyboard accessible: the file input must be triggerable without a mouse, and status changes must be announced via an ARIA live region

CONSTRAINTS
- Use only [ALLOWED LIBRARIES, e.g. no third-party upload libraries, or "react-dropzone is allowed"]
- Keep the component in [SINGLE FILE / SPLIT INTO SUBCOMPONENTS]
- Match this file naming and folder convention: [YOUR CONVENTION]

OUTPUT FORMAT
1. The complete component code in a single fenced code block, with inline comments explaining the drag event handlers and progress logic
2. A short list of the props the component expects and what each one does
3. One sentence noting any edge case the implementation does not handle, if any

Make this prompt yours

React Prompt Recipes

AI Prompt to Build a React Multi-Step Form Wizard With Validation

This is an AI prompt for building a React multi step form wizard : a form split across several steps with a progress indicator, per step val…

ROLE: You are a senior frontend engineer who specializes in React form architecture.

CONTEXT:
- Framework: [REACT VERSION, e.g. React 18 with hooks]
- Styling approach: [CSS MODULES / TAILWIND / STYLED-COMPONENTS]
- Form library preference: [NONE - PLAIN STATE / REACT HOOK FORM / FORMIK]
- Steps needed: [LIST EACH STEP AND ITS FIELDS, e.g. Step 1: Account (email, password). Step 2: Profile (name, company). Step 3: Preferences (plan, notifications)]
- Validation rules: [LIST RULES PER FIELD, e.g. email must be valid format, password min 8 characters]

TASK:
Build a multi-step form wizard component with the following requirements:
1. A shared state object holding data from all steps, so navigating back and forth never loses entered values
2. Per-step validation that blocks the "Next" button until the current step's required fields are valid, with inline error messages
3. A progress indicator showing the current step out of the total number of steps
4. Back and Next navigation, with Back always enabled (except on step 1) and Next disabled until validation passes
5. A final review step before submission showing a summary of all entered data, with the ability to jump back to any step to edit it
6. A loading/submitting state on final submit that disables the submit button to prevent double submission
7. Clear separation between step configuration (data) and the rendering logic, so adding or removing a step does not require rewriting the component

CONSTRAINTS:
- [SPECIFY ACCESSIBILITY REQUIREMENTS, e.g. keyboard navigable, ARIA labels on progress indicator]
- [SPECIFY WHETHER STATE SHOULD PERSIST ACROSS PAGE REFRESH, e.g. using localStorage or session state]
- [SPECIFY IF STEPS ARE CONDITIONAL, e.g. step 3 only appears if plan = enterprise]

OUTPUT FORMAT:
Provide the complete component code, broken into logical files or sections (step config, main wizard component, individual step components, validation logic). Add brief comments explaining the state flow between steps. After the code, list any assumptions made about fields or behavior that were not specified above.

Make this prompt yours

React Prompt Recipes

AI Prompt to Generate a React Component From a Figma File Using MCP

This prompt is for front end developers who want to turn a Figma design into working React code by connecting an AI model to Figma's MCP ser…

Role: You are a front-end developer with access to a Figma MCP connection.

Context:
- Figma file: [FILE_NAME_OR_URL]
- Frame or node to convert: [FRAME_NAME]
- Framework: React with [STYLING_APPROACH, e.g. Tailwind CSS]
- Component name: [COMPONENT_NAME]

Task:
1. Read the specified frame's layout, spacing, typography, and color values through the Figma MCP connection.
2. Generate a React component that reproduces this layout using the stated styling approach.
3. Note any interactive states (hover, focus, disabled) visible in the file and implement them if present.

Constraints:
- Use the actual measured values (padding, gap, font size, colors) from the Figma file rather than estimated or rounded values.
- Keep the component self-contained and reusable, with props for any text or image content that should be dynamic.
- Include basic accessibility attributes (alt text, semantic HTML elements, ARIA labels where relevant).
- Flag anything in the design that can't be cleanly translated to code (e.g. a custom font not available in the project).

Output format:
- Component code in a fenced code block
- Brief notes on any values that couldn't be read directly from Figma and were estimated
- List of interactive states implemented, or "None found in this frame"

Make this prompt yours

React Prompt Recipes

ChatGPT Prompt to Build a React Dashboard Layout With Sidebar and Charts

This React dashboard layout prompt helps developers get a working admin or analytics dashboard scaffold out of ChatGPT, Claude, or Gemini in…

Role: You are a senior frontend engineer specializing in React and responsive dashboard UIs.

Context:
- Framework: [REACT VERSION, e.g., React 18 with functional components and hooks]
- Styling approach: [TAILWIND CSS / CSS MODULES / STYLED-COMPONENTS]
- Charting library: [RECHARTS / CHART.JS / NIVO]
- Dashboard purpose: [e.g., SaaS analytics dashboard showing revenue, active users, and churn]

Task:
Build a dashboard layout with the following structure:
1. A collapsible sidebar with navigation links: [LIST OF NAV ITEMS]
2. A top bar with [e.g., page title, search input, user avatar menu]
3. A main content area using a responsive grid containing:
   - [NUMBER] stat/summary cards showing [METRICS, e.g., total revenue, active users, churn rate]
   - [NUMBER] chart widgets showing [CHART TYPES AND DATA, e.g., a line chart of revenue over time, a bar chart of signups by month]

Constraints:
- Break the output into separate components: Sidebar, Topbar, ChartCard, StatCard, and a parent DashboardLayout component.
- The sidebar must collapse to [OFF-CANVAS DRAWER / ICON-ONLY RAIL] on screens narrower than [BREAKPOINT, e.g., 768px].
- Include realistic mock data inline so the layout is immediately viewable without a backend.
- Use semantic HTML where applicable (nav, main, aside, header).

Output format:
- Provide each component as a separate, clearly labeled code block.
- List any npm packages that need to be installed before the code will run.
- End with a short note on what to replace with real API data.

Make this prompt yours

React Prompt Recipes

AI Prompt to Build a React Authentication Flow With Protected Routes

This AI prompt for a React authentication flow generates the pieces a typical app needs to gate pages behind a login: a login form, an auth…

ROLE
You are a senior React developer building a reusable authentication flow.

CONTEXT
Framework: [REACT_VERSION, e.g. React 18]
Routing library: [ROUTING_LIBRARY_AND_VERSION, e.g. React Router v6]
Backend auth endpoints: [LOGIN_ENDPOINT], [LOGOUT_ENDPOINT], [SESSION_CHECK_ENDPOINT]
Token storage method: [TOKEN_STORAGE_METHOD, e.g. httpOnly cookie set by the server]
Styling approach: [STYLING_APPROACH, e.g. Tailwind CSS]

TASK
Generate the following, using functional components and hooks:
1. An AuthContext and AuthProvider that exposes the current user, a loading flag, and login/logout functions.
2. A login form component that calls the login function and displays validation and API errors.
3. A ProtectedRoute component that redirects unauthenticated users to [LOGIN_ROUTE_PATH], preserving the originally requested URL for post-login redirect.
4. On initial app load, verify any existing session before rendering protected routes, showing a loading indicator during the check.

CONSTRAINTS
- Do not render protected page content until the session check has completed.
- Handle network and 401 errors from the auth endpoints gracefully, with user-facing messages.
- Keep components small and composable; do not put API calls directly inside UI components.

OUTPUT FORMAT
Provide each file separately with a filename comment at the top, followed by a 2-3 sentence summary of how the pieces connect together.

Make this prompt yours

React Prompt Recipes

ChatGPT Prompt to Build a React Data Table With Sorting, Filtering, and Pagination

This ChatGPT prompt is for frontend developers who need a working React data table component — the kind with sortable columns, a search/filt…

ROLE:
You are a senior frontend engineer who writes clean, accessible React components.

CONTEXT:
I need a React component called [COMPONENT_NAME] that displays a data table for the following data shape:
[DESCRIBE_DATA_SHAPE_E.G._ARRAY_OF_OBJECTS_WITH_FIELDS_AND_TYPES]

REQUIREMENTS:
- Columns: [LIST_COLUMN_NAMES_AND_WHICH_ARE_SORTABLE]
- Sorting: clicking a sortable column header toggles ascending/descending order, with a visible indicator of current sort state
- Filtering: a single search input that filters rows by [SPECIFY_WHICH_FIELDS_TO_MATCH], case-insensitive
- Pagination: [NUMBER] rows per page, with previous/next controls and a current page indicator
- Empty states: show a clear message when the data array is empty, and a separate message when a filter returns no results
- Accessibility: sortable headers must be keyboard-operable and expose their sort state to screen readers
- Styling approach: [SPECIFY_E.G._TAILWIND_CLASSES_OR_PLAIN_CSS_MODULES]

OUTPUT FORMAT:
Return the complete component code in a single code block, followed by a short list of any assumptions you made about data or behavior that I didn't specify.

Make this prompt yours

React Prompt Recipes

AI Prompt to Build an Accessible React Modal Component

This prompt generates an accessible React modal component , built for frontend developers who need a dialog that actually works with keyboar…

ROLE: You are a senior frontend engineer writing accessible React components.

TASK:
Build a reusable Modal component in React with [TYPESCRIPT / JAVASCRIPT].

FUNCTIONAL REQUIREMENTS:
- Opens and closes based on an `isOpen` prop and `onClose` callback
- Renders via [REACT PORTAL / INLINE] into [TARGET DOM NODE OR DESCRIPTION]
- Closes on Escape key press
- Closes on clicking the overlay background (but not when clicking inside the modal content)

ACCESSIBILITY REQUIREMENTS:
- Traps keyboard focus inside the modal while it is open
- Returns focus to the element that triggered the modal when it closes
- Uses `role="dialog"`, `aria-modal="true"`, and `aria-labelledby` pointing to the modal title
- Prevents background content from being read by screen readers while the modal is open

STYLING:
- [UNSTYLED WITH CLASS NAMES / USE TAILWIND / MATCH THIS DESIGN SYSTEM: DESCRIBE]

OUTPUT FORMAT:
Provide the complete component code in a single file, followed by a short usage example showing how to open the modal from a parent component.

Make this prompt yours

React Prompt Recipes

AI Prompt to Turn a Design Screenshot into a React Component

This is a React prompt for converting a design screenshot or mockup into working React component code — built for frontend developers who ge…

ROLE: You are a frontend developer converting a design image into a React component.

CONTEXT: I'm attaching a design screenshot/mockup. Tech stack: [REACT VERSION, STYLING APPROACH e.g. Tailwind/CSS Modules/styled-components, COMPONENT LIBRARY IF ANY]

TASK:
1. First, describe what you see in the image: overall layout, spacing, typography (font sizes/weights), colors, and any visible interactive states
2. Flag anything you're uncertain about (illegible text, ambiguous spacing, colors that are hard to read precisely) instead of guessing silently
3. Then write the React component matching this description, split into: component structure (JSX), styling, and any props needed to make it reusable

CONSTRAINTS:
- Match the layout and spacing as closely as possible to what's visible in the image
- Use [STYLING APPROACH] only, no inline styles unless the project convention requires it
- Make the component accept props for any content that would realistically vary (text, images, links)
- [ANY ADDITIONAL CONSTRAINT, e.g. must be accessible, must support dark mode]

OUTPUT FORMAT:
1. A short description of the design (layout, spacing, typography, colors, flagged uncertainties)
2. The complete component code in a fenced code block
3. A one-line note on anything that will need visual verification once rendered

Make this prompt yours

React Prompt Recipes

ChatGPT Prompt to Build a Reusable React Form Component with Validation

This ChatGPT prompt generates a reusable React form component with built in field validation, meant for frontend developers who want a worki…

Role: You are a frontend engineer who writes clean, reusable React components.

Context:
- Component purpose: [E.G., SIGNUP FORM, CONTACT FORM, SETTINGS FORM]
- Fields and validation rules: [FIELD NAME: TYPE AND RULE, repeat for each field, e.g., "email: required, must match email format"]
- State approach: [PLAIN useState, TYPESCRIPT, OR A LIBRARY LIKE REACT HOOK FORM]
- Styling approach: [CSS MODULES, TAILWIND, PLAIN CSS, OR INLINE STYLES]
- Submit behavior: [WHAT SHOULD HAPPEN ON VALID SUBMIT, E.G., "CALL AN onSubmit PROP WITH FORM VALUES"]

Constraints:
- Component must be self-contained and reusable, accepting props for initial values and onSubmit
- Each field must show its own inline error message that clears once the field becomes valid
- Submit button must be disabled while any required field is invalid

Task: Write the complete React component code implementing the form above.

Output format:
1. The full component code in a single fenced code block
2. A short explanation of the validation logic and how to use the component
3. Any assumptions made about props or styling

Make this prompt yours