Loading component…
Loading component…
The quiet bar under an AI message
To reuse this local React demo, copy all files from the Code tab into the same folder, then import MessageActions from ./message-actions.
import { MessageActions, MessageText } from "@/components/ui/message-actions";
export function AssistantMessage({ message }) {
const [version, setVersion] = useState(message.versions.length - 1);
const text = message.versions[version];
return (
// data-ui-message lets the bar light up while the whole message is hovered
<div data-ui-message>
<MessageText version={version}>{text}</MessageText>
<MessageActions
text={text}
versions={message.versions}
version={version}
onVersionChange={setVersion}
onRegenerate={() => regenerate(message.id)}
onFeedback={(kind, reason) => saveFeedback(message.id, version, kind, reason)}
/>
</div>
);
}| Name | Type | Default | Description |
|---|---|---|---|
| text | string | The message text – Copy writes it to the clipboard, and an uncontrolled read aloud is timed by its length | |
| actions | MessageActionKey[] | ["copy", "regenerate", "feedback", "speak"] | Which actions to show and in what order. feedback is the thumbs up and down |
| versions | number \| string[] | 1 | All versions of the message, or just how many there are. From two on the "‹ 2 / 3 ›" switcher unfolds next to Regenerate |
| version | number | Controlled version, 0-based | |
| defaultVersion | number | newest | Starting version when uncontrolled. Uncontrolled, the switcher jumps to a version as soon as it is added |
| onVersionChange | (index: number) => void | Called with the version picked in the switcher | |
| onCopy | (text?: string) => void | Called after Copy, with text | |
| onRegenerate | () => void | Called when Regenerate is pressed – add a version to versions and it shows up in the switcher | |
| regenerating | boolean | false | Keeps the arrow spinning and the bar lit while a new version is written |
| onFeedback | (kind: "up" \| "down" \| null, reason?: string) => void | Called with the vote right away, with null when it is taken back, and once more with "down" and a reason when the feedback row is sent. A new version starts without a vote | |
| reasons | string[] | Not accurate, Too long, Didn't follow instructions, Other | Quick reasons in the feedback row. "Other" unfolds a small text field whose words are sent as the reason |
| onSpeak | (playing: boolean) => void | Called with true when Read aloud starts and false when it stops | |
| speaking | boolean | Controlled playing state – tie it to your speech player. Without it the bar plays for speakDuration and stops on its own | |
| speakDuration | number | from text, at least 2600 | How long an uncontrolled read aloud plays, in ms |
| quiet | boolean | true | Faded until the message (an ancestor with data-ui-message) or the bar is hovered or focused. Touch screens always show it fully |
| label | string | "Message actions" | Accessible name of the bar |
| className | string | Extra class on the root |
The bar is about 230px wide with the switcher; the feedback row fills its container up to 440px and its reasons wrap
Below 320px the Send button takes its own line under the reasons
Touch screens: 38px buttons, taller reasons, no hover tooltips (only "Copied"), and the bar is never faded
Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"
@import "tailwindcss"; in your main CSS file.