Generative UI
Learn how to embed custom UI components in the chat window.
Render custom components in the chat UI
When a user interacts with your Copilot, you may want to render a custom UI component. useCopilotAction
allows to give the LLM the
option to render your custom component through the render
property.
useCopilotAction
can be used with a render
function and without a handler
to display information or UI elements within the chat.
Here's an example to render a calendar meeting.

"use client" // only necessary if you are using Next.js with the App Router.
import { useCopilotAction } from "@copilotkit/react-core";
export function YourComponent() {
useCopilotAction({
name: "showCalendarMeeting",
description: "Displays calendar meeting information",
parameters: [
{
name: "date",
type: "string",
description: "Meeting date (YYYY-MM-DD)",
required: true
},
{
name: "time",
type: "string",
description: "Meeting time (HH:mm)",
required: true
},
{
name: "meetingName",
type: "string",
description: "Name of the meeting",
required: false
}
],
render: ({ status, args }) => {
const { date, time, meetingName } = args;
if (status === 'inProgress') {
return <LoadingView />; // Your own component for loading state
} else {
const meetingProps: CalendarMeetingCardProps = {
date: date,
time,
meetingName
};
return <CalendarMeetingCardComponent {...meetingProps} />;
}
},
});
return (
<>...</>
);
}
Test it out!
After defining the action with a render method, ask the copilot to perform the task. For example, you can now ask the copilot to "show tasks" and see the custom UI component rendered in the chat interface.
You can read more about the useCopilotAction
hook
here.