Back to Copilotkit

Customize Built In Ui Components

docs/snippets/shared/guides/custom-look-and-feel/customize-built-in-ui-components.mdx

1.57.07.1 KB
Original Source

import { CopilotKitCSS, InteractiveCSSInspector } from "@/components/react/copilotkit-css";

CopilotKit has a variety of ways to customize colors and structures of the Copilot UI components.

If you want to customize the style as well as the functionality of the Copilot UI, you can also try the following:

CSS Variables (Easiest)

The easiest way to change the colors using in the Copilot UI components is to override CopilotKit CSS variables.

<Callout type="info"> Hover over the interactive UI elements below to see the available CSS variables. </Callout> <CopilotKitCSS /> <InteractiveCSSInspector />

Once you've found the right variable, you can import CopilotKitCSSProperties and simply wrap CopilotKit in a div and override the CSS variables.

tsx
import { CopilotKitCSSProperties } from "@copilotkit/react-core/v2";

<div
  // [!code highlight:5]
  style={
    {
      "--copilot-kit-primary-color": "#222222",
    } as CopilotKitCSSProperties
  }
>
  <CopilotSidebar .../>
</div>

Reference

CSS VariableDescription
--copilot-kit-primary-colorMain brand/action color - used for buttons, interactive elements
--copilot-kit-contrast-colorColor that contrasts with primary - used for text on primary elements
--copilot-kit-background-colorMain page/container background color
--copilot-kit-secondary-colorSecondary background - used for cards, panels, elevated surfaces
--copilot-kit-secondary-contrast-colorPrimary text color for main content
--copilot-kit-separator-colorBorder color for dividers and containers
--copilot-kit-muted-colorMuted color for disabled/inactive states

Custom CSS

In addition to customizing the colors, the CopilotKit CSS is structured to easily allow customization via CSS classes.

css
.copilotKitButton {
  border-radius: 0;
}

.copilotKitMessages {
  padding: 2rem;
}

.copilotKitUserMessage {
  background: #007AFF;
}

Reference

<Callout> For a full list of styles and classes used in CopilotKit, click [here](https://github.com/CopilotKit/CopilotKit/blob/main/packages/react-ui/src/css/). </Callout>
CSS ClassDescription
.copilotKitMessagesMain container for all chat messages with scroll behavior and spacing
.copilotKitInputText input container with typing area and send button
.copilotKitUserMessageStyling for user messages including background, text color and bubble shape
.copilotKitAssistantMessageStyling for AI responses including background, text color and bubble shape
.copilotKitHeaderTop bar of chat window containing title and controls
.copilotKitButtonPrimary chat toggle button with hover and active states
.copilotKitWindowRoot container defining overall chat window dimensions and position
.copilotKitMarkdownStyles for rendered markdown content including lists, links and quotes
.copilotKitCodeBlockCode snippet container with syntax highlighting and copy button
.copilotKitChatBase chat layout container handling positioning and dimensions
.copilotKitSidebarStyles for sidebar chat mode including width and animations
.copilotKitPopupStyles for popup chat mode including position and animations
.copilotKitButtonIconIcon styling within the main chat toggle button
.copilotKitButtonIconOpen .copilotKitButtonIconCloseIcon states for when chat is open/closed
.copilotKitCodeBlockToolbarTop bar of code blocks with language and copy controls
.copilotKitCodeBlockToolbarLanguageLanguage label styling in code block toolbar
.copilotKitCodeBlockToolbarButtonsContainer for code block action buttons
.copilotKitCodeBlockToolbarButtonIndividual button styling in code block toolbar
.copilotKitSidebarContentWrapperInner container for sidebar mode content
.copilotKitInputControlsContainer for input area buttons and controls
.copilotKitActivityDot1 .copilotKitActivityDot2 .copilotKitActivityDot3Animated typing indicator dots
.copilotKitDevConsoleDevelopment debugging console container
.copilotKitDevConsoleWarnOutdatedWarning styles for outdated dev console
.copilotKitVersionInfoVersion information display styles
.copilotKitDebugMenuButtonDebug menu toggle button styling
.copilotKitDebugMenuDebug options menu container
.copilotKitDebugMenuItemIndividual debug menu option styling

Custom Fonts

You can customize the fonts by updating the fontFamily property in the various CSS classes that are used in the CopilotKit.

css
.copilotKitMessages {
  font-family: "Arial, sans-serif";
}

.copilotKitInput {
  font-family: "Arial, sans-serif";
}

Reference

You can update the main content classes to change the font family for the various components.

CSS ClassDescription
.copilotKitMessagesMain container for all messages
.copilotKitInputThe input field
.copilotKitMessageBase styling for all chat messages
.copilotKitUserMessageUser messages
.copilotKitAssistantMessageAI responses

Custom Icons

You can customize the icons by passing the icons property to the CopilotSidebar, CopilotPopup or CopilotChat component.

tsx
<CopilotChat
  icons={{
    // Use your own icons here – any React nodes
    openIcon: <YourOpenIconComponent />,
    closeIcon: <YourCloseIconComponent />,
  }}
/>

Reference

IconDescription
openIconThe icon to use for the open chat button
closeIconThe icon to use for the close chat button
headerCloseIconThe icon to use for the close chat button in the header
sendIconThe icon to use for the send button
activityIconThe icon to use for the activity indicator
spinnerIconThe icon to use for the spinner
stopIconThe icon to use for the stop button
regenerateIconThe icon to use for the regenerate button
pushToTalkIconThe icon to use for push to talk

Custom Labels

To customize labels, pass the labels property to the CopilotSidebar, CopilotPopup or CopilotChat component.

tsx
<CopilotChat
  labels={{
    welcomeMessageText: "Hello! How can I help you today?",
    modalHeaderTitle: "My Copilot",
    chatInputPlaceholder: "Ask me anything!",
    stopGenerating: "Stop",
    regenerateResponse: "Regenerate",
  }}
/>

Reference

LabelDescription
welcomeMessageTextThe initial message(s) to display in the chat window
modalHeaderTitleThe title to display in the header
chatInputPlaceholderThe placeholder to display in the input
stopGeneratingThe label to display on the stop button
regenerateResponseThe label to display on the regenerate button