A modern, TypeScript-based React component library built with Vite, featuring a comprehensive collection of customizable UI components with built-in theming support.
- π¨ Comprehensive Component Library - 30+ production-ready components including forms, charts, tables, and navigation
- π Theme System - Built-in light/dark mode support with customizable themes
- π¦ Tree-shakeable - Optimized bundle size with ES modules
- π· TypeScript First - Full TypeScript support with comprehensive type definitions
- β‘ Modern Stack - Built with Vite, React 19, and SWC for optimal performance
- π Storybook Integration - Interactive component documentation and development
- β Fully Tested - Comprehensive test coverage with Vitest and React Testing Library
- βΏ Accessible - WCAG compliant components
- π― SCSS Styling - Flexible styling with SCSS and BEM methodology
npm install kai-ui
# or
yarn add kai-uiThis library requires the following peer dependencies:
npm install react react-dom @floating-ui/react react-hook-form react-icons react-tooltip react-transition-group ag-grid-community ag-grid-react clsx date-fns highcharts highcharts-react-official highcharts-custom-events lodash yupkai-ui/
βββ src/
β βββ components/ # UI components
β β βββ Accordion/
β β βββ Avatar/
β β βββ Button/
β β βββ Charts/
β β βββ DataTable/
β β βββ Forms/
β β βββ ...
β βββ hooks/ # Custom React hooks
β βββ providers/ # Context providers (Theme, etc.)
β βββ styles/ # Global styles and theming
β βββ utils/ # Utility functions
Each component follows a consistent structure:
- Component File (
*.tsx) - Main component implementation - Styles (
*.scss) - Component-specific styles using BEM methodology - Stories (
*.stories.tsx) - Storybook documentation - Tests (
*.test.tsx) - Unit tests with Vitest - Types - TypeScript interfaces exported for consumers
- Index (
index.ts) - Clean exports
- Composition over Configuration - Components are designed to be composed together
- Prop-driven - Behavior controlled through clear, typed props
- Accessibility First - ARIA attributes and keyboard navigation built-in
- Theme Integration - All components respect the global theme system
- Performance Optimized - Minimal re-renders and optimized bundle size
import { ThemeProvider } from 'kai-ui';
import 'kai-ui/styles.css';
function App() {
return <ThemeProvider name="my-app">{/* Your app content */}</ThemeProvider>;
}import { Button, Input, Modal, DataTable } from 'kai-ui';
function MyComponent() {
return (
<div>
<Button variant="primary" onClick={() => console.log('clicked')}>
Click Me
</Button>
<Input label="Email" type="email" placeholder="Enter your email" />
</div>
);
}The library includes a built-in theme system with light and dark modes:
import { useTheme } from 'kai-ui';
function ThemeToggle() {
const { theme, isDark, setTheme } = useTheme();
return <button onClick={() => setTheme(isDark ? 'light' : 'dark')}>Current: {theme}</button>;
}Theme preferences are automatically:
- Persisted to localStorage
- Synchronized with system preferences
- Applied via CSS custom properties
The library provides several custom hooks:
import { useClickOutside, useCloseByEscape, useCountdown, useEventListener, useTheme } from 'kai-ui';
function MyComponent() {
const ref = useClickOutside(() => console.log('Clicked outside'));
useCloseByEscape(() => console.log('Escape pressed'));
return <div ref={ref}>Content</div>;
}- Accordion - Collapsible content sections
- Drawer - Side panel with slide-in animation
- Modal - Dialog overlays
- SideNav - Sidebar navigation
- Tabs - Tabbed interfaces
- Stepper - Multi-step workflows
- Button - Multiple variants (primary, secondary, tertiary, ghost, danger)
- Checkbox - Single and grouped checkboxes
- ColorPicker - Color selection with presets
- DatePicker - Date and range selection
- Input - Text input with validation
- Radio - Radio button groups
- Select - Dropdown selection
- Switch - Toggle switches
- Textarea - Multi-line text input
- Forms - Complete form components with validation
- Avatar - User avatars with initials fallback
- DataRows - Key-value data display
- DataTable - Advanced data grid (powered by AG Grid)
- HeatMapCalendar - Calendar-based heatmaps
- Score - Rating display
- Label - Status badges and labels
- Chart - Base chart component
- DateTimeSeries - Time-based line charts
- PieChart - Circular data visualization
- SpiderWebChart - Radar/spider charts
- Backdrop - Modal backdrops
- Hint - Tooltips and hints
- Spinner - Loading indicators
- ContextMenu - Right-click menus
- MenuButton - Dropdown action menus
- Pagination - Page navigation controls
- PseudoLink - Link-styled buttons
- Node.js >= 22
- Yarn or npm
# Install dependencies
yarn install
# Start Storybook development server
yarn storybook
# Build the library
yarn build
# Run tests
yarn test
# Run linting
yarn lint
# Fix linting issues
yarn lint:fix
# Type checking
yarn check-types
# CI pipeline (lint + test)
yarn ciThe library is built using Vite with the following optimizations:
- TypeScript declarations generated with
vite-plugin-dts - Tree-shaking enabled with ES modules
- Code splitting for optimal chunk sizes
- SVG as React components with
vite-plugin-svgr - Minification with Terser
- Peer dependencies externalized to reduce bundle size
Build output structure:
dist/
βββ index.js # Main entry point
βββ index.d.ts # Type definitions
βββ styles.css # Bundled styles
βββ src/ # Individual component types
Tests are written using:
- Vitest - Fast unit test runner
- React Testing Library - Component testing utilities
- @testing-library/jest-dom - Custom matchers
Run tests:
yarn test # Watch mode
yarn ci # Single run (CI)Interactive component documentation is available via Storybook:
yarn storybookAccess at http://localhost:6006
Build static Storybook:
yarn storybook:buildThe library uses SCSS with a BEM-inspired methodology:
// Global styles
@import 'kai-ui/dist/styles.css';
// Component-specific
.ui-btn {
&--primary {
/* ... */
}
&--secondary {
/* ... */
}
&--small {
/* ... */
}
}Theming is implemented using CSS custom properties:
:root {
--color-primary: #007bff;
--color-background: #ffffff;
--font-family-base: 'Inter', sans-serif;
// ... more variables
}
[data-theme='dark'] {
--color-background: #1a1a1a;
// ... dark theme overrides
}The library includes custom font faces. Ensure fonts are properly loaded:
import 'kai-ui/dist/styles.css'; // Includes font facesContributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Write tests for new functionality
- Ensure all tests pass (
yarn ci) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow existing patterns and conventions
- Use TypeScript for all new code
- Write tests for components and hooks
- Document props with JSDoc comments
- Create Storybook stories for visual components
MIT Β© Kai Hotz
The library provides utility functions for common tasks:
capitalizeWords()- String formattingcleanObj()- Object sanitizationgetInitials()- Extract initials from nameshighlightText()- Text highlightingisEditableElement()- DOM element checksgetCSSVariable()- Theme variable access- And more...
Built with: