Custom Styling
CopilotKit components are fully customizable through CSS variables, Tailwind CSS classes, and component slots. This guide covers all styling approaches to match your application’s design system.Overview
CopilotKit uses a sophisticated styling system built on:- CSS Custom Properties - Theme variables prefixed with
--for colors, spacing, and borders - Tailwind CSS - Utility classes with
cpk:prefix to avoid conflicts - Component Slots - Replace or extend component parts with custom implementations
- Dark Mode - Built-in dark mode support with automatic theme switching
CSS Variables
All CopilotKit components use CSS variables defined on elements with the[data-copilotkit] attribute.
Color Variables
Override these variables to change the color scheme:Dark Mode Variables
Dark mode is automatically applied when the.dark class is present:
Custom Theme Example
Create a custom theme with your brand colors:Tailwind CSS Classes
CopilotKit uses Tailwind CSS with acpk: prefix to avoid conflicts with your application’s styles.
Using Utility Classes
Customize components by passing className props:Common Utility Patterns
Tailwind Configuration
CopilotKit’s Tailwind configuration includes theme tokens:Component Slots
Slots allow you to replace or customize specific parts of components.String Slots (Class Names)
Pass a string to add CSS classes:twMerge, so you can override default styles.
Object Slots (Props)
Pass an object to override component props:Component Slots (Custom Renderers)
Replace entire components with your own implementations:Responsive Design
Sidebar Width
Control sidebar width with CSS variables:Mobile Optimizations
CopilotKit includes mobile-specific styles:Component-Specific Styling
Chat Messages
Style individual message components:Input Field
Customize the chat input:Audio Recorder
The audio recorder uses canvas for visualization:Advanced Customization
Custom Animations
Define custom animations with Tailwind:Custom Component Example
Build a fully custom message component:Theming Best Practices
Use CSS Variables
Prefer CSS variables for theme-able values to enable easy theme switching
Maintain Contrast
Ensure sufficient contrast between foreground and background colors for accessibility
Test Dark Mode
Always test your custom themes in both light and dark modes
Namespace Carefully
Use the
cpk: prefix for all Tailwind utilities to avoid style conflictsDebugging Styles
Inspect CSS Variables
Check applied CSS variables in browser DevTools:Override Detection
Check if your overrides are applied:Example: Complete Custom Theme
Here’s a complete example combining all styling approaches:Related Resources
Component Reference
View all available components and their slot options
Tailwind CSS Docs
Learn more about Tailwind CSS utilities
