React component prompt from a plain spec

Generate a typed, accessible React component from a plain description, with props, states, styling, tests and usage examples.

Published
Works with
ChatGPT, Claude and Gemini
Level
Intermediate
By
GoodAIPromt editorial team

Asking an AI for "a React dropdown" usually gets you a demo that ignores keyboard users, loading and error states, and your project's conventions. This React component prompt starts from a clear spec: what the component does, its props, its states and your stack. It returns a typed, accessible component with tests and usage examples that fit your codebase instead of a generic snippet.

The prompt

Act as a senior frontend engineer. Build a React component.

Component: 
Stack: 
Props and behaviour: 
States to handle: 
Design notes: 
Project conventions: 

Deliver:
1. The component code with typed props, sensible defaults and short comments.
2. Accessibility: semantic HTML, keyboard support, focus management and ARIA only where needed; list what you implemented.
3. All the states I listed, handled visibly.
4. Tests with  covering rendering, interaction, keyboard use and edge cases.
5. A usage example and, if useful, a Storybook story.
6. Performance notes (memoization only where it helps).
7. Anything in my spec that is ambiguous, with the choice you made.

Don't add dependencies I haven't listed without asking.

0 of 7 blanks filled

How to use it

  1. Describe states and edge cases up front; that's where generic components fail.
  2. Run the tests and try the component with a keyboard before merging.
  3. Ask for refinements against your design system tokens.

Tips

  • Check whether your project already has a component library before building from scratch.
  • Ask for a short README section if the component will be reused by other teams.

Frequently asked questions

What does this prompt do?

Generate a typed, accessible React component from a plain description, with props, states, styling, tests and usage examples.

Which AI tools does it work with?

It is written for ChatGPT, Claude and Gemini. It also works in other AI tools that accept text prompts, with small changes.

What do I need to fill in?

7 blanks: name and what it does, e.g. a searchable select for choosing a customer; react version, typescript yes/no, styling e.g. tailwind / css modules / styled-components, state or data library; list inputs, callbacks, controlled/uncontrolled; loading, empty, error, disabled, long content; sizes, variants, responsive behaviour; file structure, naming, testing library; and more. Click each blue blank on the page, type your details and press Copy prompt.

Is this prompt free to use?

Yes. You can copy and use it for personal and commercial work.

reacttypescriptfrontendcomponents

More prompts for ChatGPT, Claude, Gemini.