Response feedback
Thumbs up and down under an AI answer, with copy and your own actions beside them. A thumbs down can ask what went wrong: reason chips and a comment.

Needs Alpine and the package's script when it has no
action(a Livewire host saving the event). See getting started. With anactionit is an ordinary form and works with no script at all.
Use it
As a form posting to your route:
<p id="answer-{{ $message->id }}">{{ $message->text }}</p>
<x-ds::response-feedback
:action="route('messages.feedback', $message)"
:value="$message->rating"
:submitted="$message->rated_at !== null"
:copy="'answer-'.$message->id"
:reasons="['wrong' => 'Not correct', 'unhelpful' => 'Not helpful', 'unsafe' => 'Harmful']"
/>
It posts feedback (up, down, or empty when the reader took it back),
reason[] and comment:
public function store(Request $request, Message $message)
{
$message->update([
'rating' => $request->input('feedback') ?: null,
'rating_reasons' => $request->input('reason', []),
'rating_comment' => $request->input('comment'),
'rated_at' => now(),
]);
return back();
}
In Livewire, with no action: every press dispatches feedback, and the
component draws the result itself.
<x-ds::response-feedback :value="$rating" :reasons="$reasons" x-on:feedback="$wire.rate($event.detail)" />
public function rate(array $feedback): void
{
// ['value' => 'down', 'reasons' => ['wrong'], 'comment' => '…']
}
More actions go in the slot, as toolbar buttons:
<x-ds::response-feedback :value="$rating" copy="answer-7">
<x-ds::toolbar-button label="Regenerate" icon="arrow-path" :iconOnly="true" :tooltip="true" wire:click="regenerate" />
</x-ds::response-feedback>
Shown only on hover, as most chat apps do: mark the message group/message.
<article class="group/message">
…
<x-ds::response-feedback :showOnHover="true" … />
</article>
It stays visible on a touch screen, while focus is in it, and once anything is pressed.
Props
| Prop | Type | Default | What it does |
|---|---|---|---|
value | up down or null | — | The saved rating, drawn pressed. |
action | string | — | A URL: the component is a form posting there (with the CSRF token). |
name | string | feedback | The field the rating posts under. |
reasons | array | [] | Chips offered after a thumbs down: words, or [value => words]. Post as reason[]. |
comment | bool | true | A comment box after a thumbs down, posting as comment. |
submitted | bool | false | The feedback was received: the thanks shows, the follow-up does not. |
copy | string | — | The id or selector of the answer's text: adds a copy button. |
size | sm md | sm | |
variant | ghost muted floating | ghost | As toolbar's; ghost has no tray. |
showOnHover | bool | false | See above. |
label | string | Response actions | The toolbar's name. |
upLabel, downLabel, copyLabel | string | Good response, Bad response, Copy | The buttons' names (and tooltips). |
moreLabel, reasonsLabel, commentLabel, sendLabel | string | Tell us more, What went wrong?, Anything else? (optional), Send | The follow-up's words. |
thanks | string | Thanks for the feedback |
| Slot | What it does |
|---|---|
| default | More toolbar buttons after copy: regenerate, share, a "more" menu. |
Events
| Event | Detail | When |
|---|---|---|
feedback | { value, reasons, comment } | A thumbs press (value is up, down, or '' for taken back), or Send after a thumbs down (value is down, with the reasons and comment). Bubbles. Cancelable: in a form with an action, cancelling stops the post and draws the result here instead. |
How it behaves
- Up and down are toggle buttons (
aria-pressed), one at a time: pressing one releases the other, and pressing the pressed one takes the rating back. - With no script each is a submit button. The pressed one posts an empty value, so a second press clears, and the server's next page draws it.
- A thumbs down opens the follow-up under the buttons: a native disclosure, in the page rather than floating, because its fields post with the rating in one form. The server opens it too, for a saved thumbs down not yet submitted.
- Once a choice is final (a thumbs up, or Send) a polite status says "Thanks for the feedback".
Accessibility
- A toolbar: one Tab stop, the arrow keys between the buttons.
- The thumbs are named "Good response" and "Bad response" and say pressed or not; their tooltips repeat the name for sighted readers.
- The thanks is a polite status outside the buttons, in the page from the start, so it is read once when it appears.
Don't
- Don't ask for a comment on a thumbs up. It is the down that needs a reason.
- Don't use
showOnHoverwhere people need to find it. It suits a transcript of many answers; on a single answer, show it.
From the package repo: edit this page on GitHub.