Skip to content

gravity-ui/aikit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

405 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AIKit Β· npm package CI storybook

UI component library for AI chats built with Atomic Design principles.

Cover image

Example image

Resources

Description

@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.

Key Features

  • 🎨 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

Project Structure

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

Installation

npm install @gravity-ui/aikit

Quick Start

import { 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
            }}
        />
    );
}

Architecture

The library is built on Atomic Design principles:

πŸ”Ή Atoms

Basic indivisible UI elements without business logic:

  • ActionButton β€” button with integrated tooltip
  • Alert β€” alert messages with variants
  • ChatDate β€” date formatting with relative dates
  • ContextIndicator β€” token context usage indicator
  • ContextItem β€” context label with remove action
  • DiffStat β€” code change statistics display
  • Disclaimer β€” disclaimer text component
  • InlineCitation β€” text citations
  • Loader β€” loading indicator
  • MarkdownRenderer β€” Yandex Flavored Markdown renderer
  • MessageBalloon β€” message wrapper
  • Shimmer β€” loading animation effect
  • SubmitButton β€” submit button with states
  • ToolIndicator β€” tool execution status indicator

πŸ”Έ Molecules

Simple combinations of atoms:

  • BaseMessage β€” base wrapper for all message types
  • ButtonGroup β€” button group with orientation support
  • InputContext β€” context management
  • PromptInputBody β€” textarea with auto-growing
  • PromptInputFooter β€” footer with action icons and submit button
  • PromptInputHeader β€” header with context items and indicator
  • PromptInputPanel β€” panel container for custom content
  • Suggestions β€” clickable suggestion buttons
  • Tabs β€” navigation tabs with delete functionality
  • ToolFooter β€” tool message footer with actions
  • ToolHeader β€” tool message header with icon and actions

πŸ”Ά Organisms

Complex components with internal logic:

  • AssistantMessage β€” AI assistant message
  • Header β€” chat header
  • MessageList β€” message list
  • PromptInput β€” message input field
  • ThinkingMessage β€” AI thinking process
  • ToolMessage β€” tool execution
  • UserMessage β€” user message

πŸ“„ Templates

Complete layouts:

  • ChatContent β€” main chat content
  • EmptyContainer β€” empty state
  • History β€” chat history

πŸ“± Pages

Full integrations:

  • ChatContainer β€” fully assembled chat

Documentation

Testing

The project uses Playwright Component Testing for visual regression testing.

Run tests

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-cache

Local testing (Linux only)

If 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:update

For detailed testing documentation, see Playwright Guide.

Development

Development and contribution instructions are available in CONTRIBUTING.md.

License

MIT

About

A comprehensive, SDK-agnostic UI library built on Atomic Design principles. Create beautiful, accessible AI chat experiences with full TypeScript support, theming, and extensive customization options.

Resources

License

Contributing

Stars

164 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors