CopilotChatUserMessage
Angular standalone component that renders a single user message with attachments, copy and edit actions, and branch navigation.
Overview
CopilotChatUserMessage renders one user message. It shows any image or file attachments, renders the message text through a renderer, and shows a toolbar with copy and edit actions. When the message belongs to a set of regenerated branches, a branch navigation control lets you step between them. It mirrors React's CopilotChatUserMessage.
The copy and edit buttons always render. The branch navigation control renders only when numberOfBranches is greater than 1.
The component is standalone and uses OnPush change detection. Reactive inputs are Angular signals.
Usage
Import the component class and use its copilot-chat-user-message selector.
import { Component, signal } from "@angular/core";
import { CopilotChatUserMessage } from "@copilotkit/angular";
import type { UserMessage } from "@ag-ui/core";
@Component({
selector: "app-user-message",
standalone: true,
imports: [CopilotChatUserMessage],
template: `
<copilot-chat-user-message
[message]="message()"
(editMessage)="onEdit($event)"
/>
`,
})
export class UserMessageComponent {
message = signal<UserMessage>({
id: "1",
role: "user",
content: "What is the weather today?",
});
onEdit(event: { message: UserMessage }) {
console.log("edit", event.message.id);
}
}Inputs
Prop
Type
Prop
Type
Prop
Type
Prop
Type
Prop
Type
Slot class inputs
Each of these passes extra CSS classes to the corresponding default sub-component.
Prop
Type
Prop
Type
Prop
Type
Prop
Type
Prop
Type
Slot component inputs
Each of these replaces the corresponding default sub-component with a component class of your own. Content-projection templates (see below) take precedence over these.
Prop
Type
Prop
Type
Prop
Type
Prop
Type
Prop
Type
Outputs
Prop
Type
Prop
Type
Slots and content projection
You can override any piece of the message by projecting a named template. A projected template takes precedence over the matching *Component input. Each template receives a typed context object.
| Template name | Context type | Replaces |
|---|---|---|
messageRenderer | MessageRendererContext ({ content: string }) | The message text renderer |
toolbar | UserMessageToolbarContext ({ children?: any }) | The whole toolbar |
copyButton | CopyButtonContext ({ content?: string; copied?: boolean }) | The copy button |
editButton | EditButtonContext (empty; click via outputs) | The edit button |
branchNavigation | BranchNavigationContext ({ currentBranch, numberOfBranches, onSwitchToBranch?, message }) | The branch navigation control |
<copilot-chat-user-message [message]="message()">
<ng-template #messageRenderer let-content="content">
<p class="my-user-text">{{ content }}</p>
</ng-template>
</copilot-chat-user-message>Related
CopilotChatMessageView
Renders a list of messages, routing each to assistant, user, reasoning, or activity rendering.
CopilotChatAssistantMessage
Renders a single assistant message with markdown content, a toolbar, and tool calls.
CopilotChatView
The full chat layout: scroll container, message view, and input.