Production-ready React UI components library for building deeply-integrated AI assistants and copilots
CopilotKit React UI provides production-ready chat interface components for building AI-powered copilots in React applications. It offers flexible chat components (embedded, popup, and sidebar layouts), complete customization options, and seamless integration with the CopilotKit framework.
npm install @copilotkit/react-uiimport {
CopilotChat,
CopilotPopup,
CopilotSidebar,
useCopilotChatSuggestions,
} from "@copilotkit/react-ui";
import "@copilotkit/react-ui/styles.css";For CommonJS:
const {
CopilotChat,
CopilotPopup,
CopilotSidebar,
useCopilotChatSuggestions,
} = require("@copilotkit/react-ui");
require("@copilotkit/react-ui/styles.css");import { CopilotKit } from "@copilotkit/react-core";
import { CopilotPopup } from "@copilotkit/react-ui";
import "@copilotkit/react-ui/styles.css";
function App() {
return (
<CopilotKit runtimeUrl="/api/copilotkit">
<YourApp />
<CopilotPopup
instructions="You are a helpful assistant."
labels={{
title: "My Assistant",
initial: "Hi! How can I help you today?",
}}
/>
</CopilotKit>
);
}CopilotKit React UI is built around several key architectural patterns:
CopilotChat, CopilotPopup, CopilotSidebar) that provide different UI patterns for the same chat functionalityThree production-ready chat layouts for different UI patterns, all sharing the same core functionality with different presentation styles.
function CopilotChat(props: CopilotChatProps): JSX.Element;
function CopilotPopup(props: CopilotModalProps): JSX.Element;
function CopilotSidebar(props: CopilotModalProps): JSX.Element;Default and customizable components for rendering different message types in the chat interface.
function AssistantMessage(props: AssistantMessageProps): JSX.Element;
function UserMessage(props: UserMessageProps): JSX.Element;
function ImageRenderer(props: ImageRendererProps): JSX.Element;
function Markdown(props: { content: string; components?: ComponentsMap }): JSX.Element;Comprehensive customization options including icons, labels, CSS properties, and custom component renderers.
interface CopilotChatIcons {
openIcon?: React.ReactNode;
closeIcon?: React.ReactNode;
headerCloseIcon?: React.ReactNode;
sendIcon?: React.ReactNode;
activityIcon?: React.ReactNode;
spinnerIcon?: React.ReactNode;
stopIcon?: React.ReactNode;
regenerateIcon?: React.ReactNode;
pushToTalkIcon?: React.ReactNode;
copyIcon?: React.ReactNode;
thumbsUpIcon?: React.ReactNode;
thumbsDownIcon?: React.ReactNode;
uploadIcon?: React.ReactNode;
}
interface CopilotChatLabels {
initial?: string | string[];
title?: string;
placeholder?: string;
error?: string;
stopGenerating?: string;
regenerateResponse?: string;
copyToClipboard?: string;
thumbsUp?: string;
thumbsDown?: string;
copied?: string;
}
interface CopilotKitCSSProperties extends React.CSSProperties {
"--copilot-kit-primary-color"?: string;
"--copilot-kit-contrast-color"?: string;
"--copilot-kit-background-color"?: string;
"--copilot-kit-input-background-color"?: string;
"--copilot-kit-secondary-color"?: string;
"--copilot-kit-secondary-contrast-color"?: string;
"--copilot-kit-separator-color"?: string;
"--copilot-kit-muted-color"?: string;
"--copilot-kit-error-background"?: string;
"--copilot-kit-error-border"?: string;
"--copilot-kit-error-text"?: string;
"--copilot-kit-shadow-sm"?: string;
"--copilot-kit-shadow-md"?: string;
"--copilot-kit-shadow-lg"?: string;
"--copilot-kit-dev-console-bg"?: string;
"--copilot-kit-dev-console-text"?: string;
}React hooks for chat suggestions and accessing chat context.
function useCopilotChatSuggestions(
config: UseCopilotChatSuggestionsConfiguration,
dependencies?: any[]
): void;
function useChatContext(): ChatContext;
interface ChatContext {
labels: Required<CopilotChatLabels>;
icons: Required<CopilotChatIcons>;
open: boolean;
setOpen: (open: boolean) => void;
}Comprehensive TypeScript interfaces and types for all components and configurations.
interface CopilotChatProps {
instructions?: string;
suggestions?: ChatSuggestions;
onInProgress?: (inProgress: boolean) => void;
onSubmitMessage?: (message: string) => void | Promise<void>;
className?: string;
// ... extensive prop interface
}
interface CopilotModalProps extends CopilotChatProps {
defaultOpen?: boolean;
clickOutsideToClose?: boolean;
hitEscapeToClose?: boolean;
shortcut?: string;
onSetOpen?: (open: boolean) => void;
// ... modal-specific props
}Development tools for debugging CopilotKit applications.
function CopilotDevConsole(): JSX.Element | null;
function shouldShowDevConsole(showDevConsole: boolean): boolean;Install with Tessl CLI
npx tessl i tessl/npm-copilotkit--react-ui@1.10.1