UI component library for AI chats built with Atomic Design principles.
@gravity-ui/aikit is a flexible and extensible React component library for building AI chats of any complexity. The library provides a set of ready-made components that can be used as-is or customized to fit your needs.
- π¨ Atomic Design β clear component hierarchy from atoms to pages
- π§ SDK Agnostic β independent of specific AI SDKs
- π Two-Level Approach β ready-made components + hooks for customization
- π¨ CSS Variables β easy theming without component overrides
- π¦ TypeScript β full type safety out of the box
- π Extensible β custom message type registration system
src/
βββ components/
β βββ atoms/ # Basic indivisible UI elements
β βββ molecules/ # Simple groups of atoms
β βββ organisms/ # Complex components with logic
β βββ templates/ # Complete layouts
β βββ pages/ # Full integrations with data
βββ hooks/ # General purpose hooks
βββ types/ # TypeScript types
βββ utils/ # Utilities
βββ themes/ # CSS themes and variables
npm install @gravity-ui/aikitimport { ChatContainer } from '@gravity-ui/aikit';
import type { ChatType, TChatMessage } from '@gravity-ui/aikit';
function App() {
const [messages, setMessages] = useState<TChatMessage[]>([]);
const [chats, setChats] = useState<ChatType[]>([]);
const [activeChat, setActiveChat] = useState<ChatType | null>(null);
return (
<ChatContainer
chats={chats}
activeChat={activeChat}
messages={messages}
onSendMessage={async (data) => {
// Your sending logic
console.log('Message:', data.content);
}}
onSelectChat={setActiveChat}
onCreateChat={() => {
// Create new chat
}}
onDeleteChat={(chat) => {
// Delete chat
}}
/>
);
}The library is built on Atomic Design principles:
Basic indivisible UI elements without business logic:
ActionButtonβ button with integrated tooltipAlertβ alert messages with variantsChatDateβ date formatting with relative datesContextIndicatorβ token context usage indicatorContextItemβ context label with remove actionDiffStatβ code change statistics displayDisclaimerβ disclaimer text componentInlineCitationβ text citationsLoaderβ loading indicatorMarkdownRendererβ Yandex Flavored Markdown rendererMessageBalloonβ message wrapperShimmerβ loading animation effectSubmitButtonβ submit button with statesToolIndicatorβ tool execution status indicator
Simple combinations of atoms:
BaseMessageβ base wrapper for all message typesButtonGroupβ button group with orientation supportInputContextβ context managementPromptInputBodyβ textarea with auto-growingPromptInputFooterβ footer with action icons and submit buttonPromptInputHeaderβ header with context items and indicatorPromptInputPanelβ panel container for custom contentSuggestionsβ clickable suggestion buttonsTabsβ navigation tabs with delete functionalityToolFooterβ tool message footer with actionsToolHeaderβ tool message header with icon and actions
Complex components with internal logic:
AssistantMessageβ AI assistant messageHeaderβ chat headerMessageListβ message listPromptInputβ message input fieldThinkingMessageβ AI thinking processToolMessageβ tool executionUserMessageβ user message
Complete layouts:
ChatContentβ main chat contentEmptyContainerβ empty stateHistoryβ chat history
Full integrations:
ChatContainerβ fully assembled chat
The project uses Playwright Component Testing for visual regression testing.
Important: All tests must be run via Docker to ensure consistent screenshots across different environments.
# Run all component tests in Docker (recommended)
npm run playwright:docker
# Update screenshot baselines in Docker
npm run playwright:docker:update
# Run specific test by grep pattern in Docker
npm run playwright:docker -- --grep "@ComponentName"
# Clear Docker cache if needed
npm run playwright:docker:clear-cacheIf you're on Linux, you can run tests locally:
# Install Playwright browsers (run once)
npm run playwright:install
# Run all component tests
npm run playwright
# Update screenshot baselines
npm run playwright:updateFor detailed testing documentation, see Playwright Guide.
Development and contribution instructions are available in CONTRIBUTING.md.
MIT