Components/AI

Answer Controls Bar

Interactive control bar for AI answers with copy, like, dislike, and regenerate functionality

Live Preview
Open in
2:34

Example

export default function AnswerControlsBarExample() {
  const handleCopy = () => {
    console.log('Answer copied to clipboard')
  }

  const handleLike = () => {
    console.log('Answer liked')
  }

  const handleDislike = () => {
    console.log('Answer disliked')
  }

  const handleRegenerate = () => {
    console.log('Regenerating answer')
  }

  return (
    <div className="border rounded-lg p-4 bg-white dark:bg-gray-800">
      <p className="text-gray-700 dark:text-gray-300 mb-4">
        This is a sample AI-generated answer that demonstrates the control bar functionality. 
        You can copy, like, dislike, or regenerate this content using the controls below.
      </p>
      
      <AnswerControlsBar
        timestamp="1:45"
        copied={false}
        onCopy={handleCopy}
        onLike={handleLike}
        onDislike={handleDislike}
        onRegenerate={handleRegenerate}
      />
    </div>
  )
}

Documentation

PropTypeDefaultDescription
timestampstring"00:00"Timestamp displayed on the left side
copiedbooleanfalseWhether the content has been copied
onCopy() => voidundefinedCallback when copy button is clicked
onLike() => voidundefinedCallback when like button is clicked
onDislike() => voidundefinedCallback when dislike button is clicked
onRegenerate() => voidundefinedCallback when regenerate button is clicked

Types

interface AnswerControlsBarProps {
  timestamp?: string
  copied?: boolean
  onCopy?: () => void
  onLike?: () => void
  onDislike?: () => void
  onRegenerate?: () => void
}

Features

  • Copy Functionality: One-click copy with visual feedback and success state
  • Like/Dislike System: Interactive feedback system with toggle states
  • Regenerate Option: Quick regeneration with dropdown menu for additional options
  • Timestamp Display: Shows when the answer was generated
  • Responsive Design: Adapts to different screen sizes with mobile-friendly controls
  • Dark Mode Support: Full dark mode compatibility with appropriate styling
  • Accessibility Focused: Proper ARIA labels and keyboard navigation support
  • Visual Feedback: Clear visual states for all interactive elements