DeepSeek React Component Builder Prompt
You are a senior React developer who writes clean, performant, and accessible components.
Category
💻 Coding
Difficulty
Intermediate
Models
3
Last Updated
2026-06-28
Works with
📄 Example output
⚠️ Common Mistakes
❓ FAQ
⚙️ Fill in your variables
📋 Prompt
You are a senior React developer who writes clean, performant, and accessible components.
Component: [component name]
Purpose: [what it does]
Props: [props needed]
Styling: [styling approach — Tailwind/CSS Modules/styled-components/plain CSS]
Task: Build a complete React component including:
1. TYPESCRIPT INTERFACE: Full prop type definitions with JSDoc comments
2. THE COMPONENT:
- Functional component with correct hooks
- Error state, loading state, and empty state handled
- Accessibility: ARIA labels, keyboard navigation, focus management
3. CUSTOM HOOKS (if applicable): Extract business logic from UI
4. USAGE EXAMPLES: 3 different use cases showing the component
5. TESTING GUIDE: 5 test cases (Jest + React Testing Library)
Format: TypeScript throughout. Code blocks with syntax highlighting.
Component: [component name]
Purpose: [what it does]
Props: [props needed]
Styling: [styling approach — Tailwind/CSS Modules/styled-components/plain CSS]
Task: Build a complete React component including:
1. TYPESCRIPT INTERFACE: Full prop type definitions with JSDoc comments
2. THE COMPONENT:
- Functional component with correct hooks
- Error state, loading state, and empty state handled
- Accessibility: ARIA labels, keyboard navigation, focus management
3. CUSTOM HOOKS (if applicable): Extract business logic from UI
4. USAGE EXAMPLES: 3 different use cases showing the component
5. TESTING GUIDE: 5 test cases (Jest + React Testing Library)
Format: TypeScript throughout. Code blocks with syntax highlighting.
// SearchableDropdown.tsx
import { useState, useRef, useEffect, useCallback } from 'react';
/** Option item in the dropdown list */
interface Option {
value: string;
label: string;
disabled?: boolean;
}
/** Props for the SearchableDropdown component */
interface SearchableDropdownProps {
/** Array of options to display */
options: Option[];
/** Currently selected value */
value: string | null;
/** Callback fired when selection changes */
onChange: (value: string) => void;
/** Placeholder text for the search input */
placeholder?: string;
/** Disable the entire dropdown */
disabled?: boolean;
/** Custom class name for the container */
className?: string;
}
export function SearchableDropdown({
options,
value,
onChange,
placeholder = 'Search...',
disabled = false,
className = '',
}: SearchableDropdownProps) {
const [isOpen, setIsOpen] = useState(false);
const [search, setSearch] = useState('');
const inputRef = useRef<HTMLInputElement>(null);
const filtered = options.filter(o =>
o.label.toLowerCase().includes(search.toLowerCase())
);
// Close on outside click
useEffect(() => {
const handler = (e: MouseEvent) => {
if (!inputRef.current?.closest('.dropdown-root')?.contains(e.target as Node)) {
setIsOpen(false);
}
};
document.addEventListener('mousedown', handler);
return () => document.removeEventListener('mousedown', handler);
}, []);
...
import { useState, useRef, useEffect, useCallback } from 'react';
/** Option item in the dropdown list */
interface Option {
value: string;
label: string;
disabled?: boolean;
}
/** Props for the SearchableDropdown component */
interface SearchableDropdownProps {
/** Array of options to display */
options: Option[];
/** Currently selected value */
value: string | null;
/** Callback fired when selection changes */
onChange: (value: string) => void;
/** Placeholder text for the search input */
placeholder?: string;
/** Disable the entire dropdown */
disabled?: boolean;
/** Custom class name for the container */
className?: string;
}
export function SearchableDropdown({
options,
value,
onChange,
placeholder = 'Search...',
disabled = false,
className = '',
}: SearchableDropdownProps) {
const [isOpen, setIsOpen] = useState(false);
const [search, setSearch] = useState('');
const inputRef = useRef<HTMLInputElement>(null);
const filtered = options.filter(o =>
o.label.toLowerCase().includes(search.toLowerCase())
);
// Close on outside click
useEffect(() => {
const handler = (e: MouseEvent) => {
if (!inputRef.current?.closest('.dropdown-root')?.contains(e.target as Node)) {
setIsOpen(false);
}
};
document.addEventListener('mousedown', handler);
return () => document.removeEventListener('mousedown', handler);
}, []);
...
🏆
💡 Pro Tips
Best model for this prompt
DeepSeek
DeepSeek V3 / R1
Split large components into smaller ones early — a component over 200 lines is usually doing too much
Co-locate related code: types, component, hooks, and tests for one component should be in the same folder
Use React DevTools Profiler before optimising performance — measure first, optimise second
Accessibility is not optional: every interactive element needs a keyboard handler and appropriate ARIA attributes
Putting everything in one mega-component — makes testing, reuse, and debugging dramatically harder
Over-using useEffect for things that can be calculated during render — derived state doesn't need an effect
Missing the dependency array in useEffect — causes either infinite loops or stale closures
Using array index as the key prop in lists that can change order — causes subtle rendering bugs
- Should I use Claude or DeepSeek for React components?Both are excellent. DeepSeek V3 tends to produce more concise, idiomatic React. Claude is stronger at following complex accessibility and prop design requirements precisely.
- Does this work for Next.js components?Yes — specify 'Next.js 15 with App Router' in your [component name] description and note whether it's a Server Component or Client Component ('use client'). The AI will generate the appropriate component type.
- Can I generate components with shadcn/ui?Yes — specify 'styled with shadcn/ui components' in the [styling approach] field. The generated component will import from @/components/ui/... and follow shadcn patterns.
- What about React Native?Specify 'React Native' in the component name or add a note. Core patterns (hooks, state, TypeScript) are similar, but the styling system (StyleSheet vs. CSS) and components (View/Text vs. div/p) differ.