Feedback Buttons
AI & ChatThumbs up and down response feedback.
Preview
Usage
example.jsx
import { FeedbackButtons } from "@/components/ui/feedback-buttons";
export default function Example() {
return <FeedbackButtons />;
}Source Code
Copy this file into components/ui/feedback-buttons.jsx in your project.
feedback-buttons.jsx
import { forwardRef } from "react";
import { cn } from "@/lib/utils";
const FeedbackButtons = forwardRef(({ className, onFeedback, ...props }, ref) => (
<div ref={ref} className={cn("flex items-center gap-1", className)} {...props}>
<button onClick={() => onFeedback?.("up")}
className="inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground"
title="Helpful">
<svg className="h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M14 9V5a3 3 0 00-3-3l-4 9v11h11.28a2 2 0 002-1.7l1.38-9a2 2 0 00-2-2.3H14z" /></svg>
</button>
<button onClick={() => onFeedback?.("down")}
className="inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground"
title="Not helpful">
<svg className="h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M10 15v4a3 3 0 003 3l4-9V2H5.72a2 2 0 00-2 1.7l-1.38 9a2 2 0 002 2.3H10z" /></svg>
</button>
<button onClick={() => onFeedback?.("copy")}
className="inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground"
title="Copy">
<svg className="h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><rect x="9" y="9" width="13" height="13" rx="2" ry="2" strokeWidth={2} /><path strokeWidth={2} d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1" /></svg>
</button>
</div>
));
FeedbackButtons.displayName = "FeedbackButtons";
export { FeedbackButtons };
Quick Install
Make sure you have the cn() utility set up. It requires clsx and tailwind-merge.
npm install clsx tailwind-merge