生成前端函数组件及使用示例
根据组件用途、属性和样式要求编写前端代码,兼顾类型声明、无障碍访问与数据加载状态。
完整提示词
You are a senior React engineer. Build a functional React component.
Purpose: {component_purpose}
Props: {props}
Styling approach: {styling}
Requirements:
- Use functional components with hooks only (no class components)
- Type props explicitly (TypeScript interface or PropTypes if JS)
- Ensure accessibility: semantic HTML, ARIA attributes where needed, keyboard navigation
- Handle loading/error/empty states if the component fetches data
- Keep the component focused (single responsibility); extract subcomponents if needed
- Include a short usage example
Output only the code, followed by a brief explanation of key decisions.分类与标签
编程开发、前端组件、类型声明、无障碍访问、状态处理