Components / AI Chat Interfaces

AI Response Actions

An action bar for AI responses with copy, regenerate, thumbs up/down, and share buttons with tooltip labels.

tsx
"use client";

import React, { useState } from "react";
import { Copy, RotateCcw, ThumbsUp, ThumbsDown, Share2, Check } from "lucide-react";

interface AIResponseActionsProps {
  content: string;
  onRegenerate?: () => void;
}

export default function AIResponseActions({ content, onRegenerate }: AIResponseActionsProps) {
  const [copied, setCopied] = useState(false);
  const [feedback, setFeedback] = useState<"up" | "down" | null>(null);

  const handleCopy = async () => {
    await navigator.clipboard.writeText(content);
    setCopied(true);
    setTimeout(() => setCopied(false), 2000);
  };

  const actions = [
    {
      icon: copied ? <Check className="h-3.5 w-3.5" /> : <Copy className="h-3.5 w-3.5" />,
      label: copied ? "Copied!" : "Copy",
      onClick: handleCopy,
    },
    { icon: <RotateCcw className="h-3.5 w-3.5" />, label: "Regenerate", onClick: onRegenerate },
    {
      icon: <ThumbsUp className={`h-3.5 w-3.5 ${feedback === "up" ? "fill-current" : ""}`} />,
      label: "Good",
      onClick: () => setFeedback(feedback === "up" ? null : "up"),
      active: feedback === "up",
    },
    {
      icon: <ThumbsDown className={`h-3.5 w-3.5 ${feedback === "down" ? "fill-current" : ""}`} />,
      label: "Bad",
      onClick: () => setFeedback(feedback === "down" ? null : "down"),
      active: feedback === "down",
    },
    { icon: <Share2 className="h-3.5 w-3.5" />, label: "Share", onClick: () => {} },
  ];

  return (
    <div className="flex items-center gap-0.5">
      {actions.map((action, i) => (
        <button
          key={i}
          onClick={action.onClick}
          title={action.label}
          className={`p-1.5 rounded-md transition-colors ${
            action.active
              ? "text-violet-500 bg-violet-50 dark:bg-violet-900/20"
              : "text-zinc-400 hover:text-zinc-600 dark:hover:text-zinc-300 hover:bg-zinc-100 dark:hover:bg-zinc-800"
          }`}
        >
          {action.icon}
        </button>
      ))}
    </div>
  );
}

Installation

Dependencies

  • react
  • lucide-react
                            npm install react lucide-react
                        

Related Components

  • AI Chat Bubble — A conversational chat bubble component with typing indicator, avatar support, and message timestamps for AI chat interfaces.
  • AI Chat Input Bar — A modern chat input bar with send button, attachment support, and auto-resize textarea for AI conversation interfaces.
  • AI Chat Window — A full-featured AI chat window with message history, streaming response animation, and conversation management.
  • AI Streaming Text — A typewriter-style streaming text component that simulates token-by-token AI response generation with cursor animation.
  • AI Chat Sidebar — A conversation history sidebar listing previous AI chat sessions with search, date grouping, and active state indicators.
  • AI Model Selector — A dropdown model selector for choosing between AI models (GPT-4, Claude, Gemini) with model info badges and capability indicators.