Components/AI
Generated Answer
AI-generated answer component with progressive text reveal, markdown support, and interactive controls
2:15
Example
export default function GeneratedAnswerExample() {
const sampleContent = `# React Best Practices
## Component Structure
- Use functional components with hooks
- Keep components small and focused
- Implement proper prop validation
## State Management
- Use useState for local state
- Consider Context API for shared state
- Implement proper error boundaries
## Performance Optimization
- Use React.memo for expensive components
- Implement proper key props in lists
- Avoid unnecessary re-renders
\`\`\`jsx
const MyComponent = ({ data }) => {
const [state, setState] = useState(null)
useEffect(() => {
// Handle side effects
}, [data])
return <div>{data}</div>
}
\`\`\``
const handleEndAnimation = () => {
console.log('Text animation ended')
}
const handleComplete = () => {
console.log('Answer generation completed')
}
return (
<GeneratedAnswer
content={sampleContent}
timestamp="1:23"
isLoading={false}
textSpeed={30}
markdownMode={true}
hideControls={false}
onEndAnimation={handleEndAnimation}
onComplete={handleComplete}
className="w-full max-w-2xl"
/>
)
}
Documentation
Prop | Type | Default | Description |
---|---|---|---|
className | string | undefined | Additional CSS classes for styling |
content | string | "" | The answer content to display |
timestamp | string | "00:00" | Timestamp displayed in the controls |
isLoading | boolean | false | Whether to show loading state |
LoaderComponent | React.ReactNode | undefined | Custom loader component |
onEndAnimation | () => void | undefined | Callback when text animation ends |
onComplete | () => void | undefined | Callback when answer generation completes |
textSpeed | number | 30 | Speed of progressive text reveal |
markdownMode | boolean | false | Whether to render content as markdown |
hideControls | boolean | false | Whether to hide the control buttons |
Types
type GeneratedAnswerProps = {
className?: string
content?: string
timestamp?: string
isLoading?: boolean
LoaderComponent?: React.ReactNode
onEndAnimation?: () => void
onComplete?: () => void
textSpeed?: number
markdownMode?: boolean
hideControls?: boolean
}
Features
- Progressive Text Reveal: Animated text appearance with configurable speed
- Markdown Support: Full markdown rendering with syntax highlighting
- Loading States: Customizable loading indicators and states
- Interactive Controls: Copy, like, dislike, and regenerate functionality
- Timestamp Display: Shows when the answer was generated
- Responsive Design: Adapts to different screen sizes with proper text wrapping
- Dark Mode Support: Full dark mode compatibility with appropriate styling
- Accessibility Focused: Proper ARIA labels and keyboard navigation support