UNPKG

@keypix/ui

Version:

A premium React component library built with TypeScript, Tailwind CSS, and Atomic Design principles. The most comprehensive and beautiful UI library available.

518 lines (405 loc) โ€ข 11.7 kB
# ๐ŸŽจ Keypix UI > **A premium React component library built with TypeScript and Atomic Design principles. The most comprehensive and beautiful UI library available.** [![npm version](https://badge.fury.io/js/keypix-ui.svg)](https://badge.fury.io/js/keypix-ui) [![bundle size](https://img.shields.io/bundlephobia/minzip/keypix-ui)](https://bundlephobia.com/result?p=keypix-ui) [![TypeScript](https://img.shields.io/badge/TypeScript-007ACC?logo=typescript&logoColor=white)](https://www.typescriptlang.org/) [![License](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE) <div align="center"> ![Keypix UI Demo](https://keypix.uz/favicon.png) **Lightweight โ€ข Accessible โ€ข Customizable โ€ข TypeScript โ€ข Zero Config** [๐Ÿ“– Documentation](https://ui.keypix.uz/docs) โ€ข [๐ŸŽจ Live Demo](#live-demo) โ€ข [๐Ÿš€ Quick Start](#quick-start) โ€ข [๐Ÿ’ก Examples](#examples) </div> ## โœจ Features - ๐Ÿš€ **Ultra Lightweight** - Only 13.47 KB gzipped - ๐ŸŽฏ **Zero Configuration** - Works out of the box - โ™ฟ **Accessible** - WCAG 2.1 AA compliant - ๐ŸŽจ **Beautiful Design** - Modern, clean aesthetics - ๐Ÿ”ง **Fully Customizable** - CSS variables & themes - ๐Ÿ“ฑ **Responsive** - Mobile-first approach - ๐ŸŒ™ **Dark Mode** - Built-in theme switching - โšก **High Performance** - Optimized for speed - ๐Ÿ”’ **Type Safe** - Full TypeScript support - ๐Ÿงฉ **Atomic Design** - Scalable component architecture ## ๐Ÿ“ฆ Installation ```bash npm install keypix-ui # or yarn add keypix-ui # or pnpm add keypix-ui ``` ## ๐Ÿš€ Quick Start ### 1. Install the library ```bash npm install keypix-ui ``` ### 2. Import and use components ```tsx import { Button, Input, Card, ThemeProvider } from 'keypix-ui' function App() { return ( <ThemeProvider> <div className="keypix-p-8"> <Card> <CardHeader> <CardTitle>Welcome to Keypix UI</CardTitle> </CardHeader> <CardContent> <Input placeholder="Enter your name" /> <Button>Get Started</Button> </CardContent> </Card> </div> </ThemeProvider> ) } ``` **That's it!** ๐ŸŽ‰ No configuration needed. Styles are automatically injected. ## ๐ŸŽฏ Auto-Styling Keypix UI automatically applies global styles when imported, including: ```css * { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; font-family: 'Inter', sans-serif; } *:focus, *:active { outline: none; } html, body { height: 100%; } ``` These styles provide a clean foundation for your application. The Inter font is automatically loaded from Google Fonts. ## ๐ŸŽจ Live Demo See all components in action with our interactive demo: ```bash # Clone the repository git clone https://github.com/keypix-tech/ui.git cd keypix-ui # Install dependencies npm install # Start the demo npm run dev ``` Then open [http://localhost:5173](http://localhost:5173) in your browser to see the complete component showcase with: - All button variants and states - Form inputs with validation - Badges and avatars - Loading spinners - Search bars and modals - Data tables - Theme switching (Light/Dark/System) - Responsive design examples ## ๐ŸŽจ Components ### Atoms - [Button](./docs/components/button.md) - Versatile button with multiple variants - [Input](./docs/components/input.md) - Form input with validation states - [Badge](./docs/components/badge.md) - Status indicators and labels - [Avatar](./docs/components/avatar.md) - User profile images - [Spinner](./docs/components/spinner.md) - Loading indicators ### Molecules - [SearchBar](./docs/components/search-bar.md) - Search input with actions - [Alert](./docs/components/alert.md) - Notification messages - [Modal](./docs/components/modal.md) - Overlay dialogs ### Organisms - [Header](./docs/components/header.md) - Page navigation - [DataTable](./docs/components/data-table.md) - Tabular data display ### Providers - [ThemeProvider](./docs/components/theme-provider.md) - Theme management ## ๐Ÿ’ก Examples ### Basic Button Usage ```tsx import { Button } from 'keypix-ui' // Different variants <Button variant="default">Default</Button> <Button variant="secondary">Secondary</Button> <Button variant="destructive">Delete</Button> <Button variant="outline">Outline</Button> <Button variant="ghost">Ghost</Button> <Button variant="link">Link</Button> // Different sizes <Button size="sm">Small</Button> <Button size="md">Medium</Button> <Button size="lg">Large</Button> // With loading state <Button loading>Processing...</Button> // With icons <Button leftIcon={<DownloadIcon />}>Download</Button> ``` ### Form with Validation ```tsx import { Input, Button, Card } from 'keypix-ui' function ContactForm() { const [email, setEmail] = useState('') const [error, setError] = useState('') return ( <Card> <CardHeader> <CardTitle>Contact Us</CardTitle> </CardHeader> <CardContent> <Input type="email" placeholder="Enter your email" value={email} onChange={(e) => setEmail(e.target.value)} error={!!error} helperText={error} /> <Button onClick={handleSubmit} loading={isSubmitting} disabled={!email} > Send Message </Button> </CardContent> </Card> ) } ``` ### Theme Switching ```tsx import { ThemeProvider, useTheme, Button } from 'keypix-ui' function ThemeToggle() { const { theme, setTheme } = useTheme() return ( <div className="keypix-flex keypix-gap-2"> <Button variant={theme === 'light' ? 'default' : 'outline'} onClick={() => setTheme('light')} > Light </Button> <Button variant={theme === 'dark' ? 'default' : 'outline'} onClick={() => setTheme('dark')} > Dark </Button> <Button variant={theme === 'system' ? 'default' : 'outline'} onClick={() => setTheme('system')} > System </Button> </div> ) } function App() { return ( <ThemeProvider defaultTheme="system"> <ThemeToggle /> {/* Your app content */} </ThemeProvider> ) } ``` ## ๐ŸŽจ Customization ### CSS Variables Keypix UI uses CSS variables for easy customization: ```css :root { --primary: 221.2 83.2% 53.3%; --primary-foreground: 210 40% 98%; --secondary: 210 40% 96%; --secondary-foreground: 222.2 84% 4.9%; --background: 0 0% 100%; --foreground: 222.2 84% 4.9%; --border: 214.3 31.8% 91.4%; --radius: 0.5rem; } .dark { --background: 222.2 84% 4.9%; --foreground: 210 40% 98%; /* ... other dark theme variables */ } ``` ### Custom Theme ```tsx import { ThemeProvider } from 'keypix-ui' function App() { return ( <ThemeProvider defaultTheme="dark" storageKey="my-app-theme" > {/* Your app */} </ThemeProvider> ) } ``` ### Component Styling ```tsx // Using className prop <Button className="keypix-bg-red-500 hover:keypix-bg-red-600"> Custom Button </Button> // Using CSS variables <Button style={{ '--primary': '220 13% 91%' }}> Custom Primary </Button> ``` ## ๐Ÿ“ฑ Responsive Design All components are mobile-first and responsive: ```tsx // Responsive grid <div className="keypix-grid keypix-grid-cols-1 md:keypix-grid-cols-2 lg:keypix-grid-cols-3 keypix-gap-4"> <Card>Card 1</Card> <Card>Card 2</Card> <Card>Card 3</Card> </div> // Responsive spacing <div className="keypix-p-4 md:keypix-p-6 lg:keypix-p-8"> Content with responsive padding </div> ``` ## โ™ฟ Accessibility Keypix UI is built with accessibility in mind: - **WCAG 2.1 AA compliant** - **Keyboard navigation** support - **Screen reader** friendly - **High contrast** mode support - **Reduced motion** preferences - **ARIA attributes** on all components ```tsx // Accessible button with proper labels <Button aria-label="Download file" aria-describedby="download-description" > Download </Button> <div id="download-description" className="keypix-sr-only"> Downloads the current file in PDF format </div> ``` ## ๐Ÿ”ง API Reference ### Button ```tsx interface ButtonProps { variant?: 'default' | 'secondary' | 'destructive' | 'outline' | 'ghost' | 'link' | 'success' | 'warning' | 'info' size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'icon' loading?: boolean loadingText?: string leftIcon?: React.ReactNode rightIcon?: React.ReactNode fullWidth?: boolean disabled?: boolean ariaLabel?: string ariaDescription?: string ariaLive?: 'off' | 'polite' | 'assertive' } ``` ### Input ```tsx interface InputProps { label?: string helperText?: string error?: boolean required?: boolean leftIcon?: React.ReactNode rightIcon?: React.ReactNode // ... all standard input props } ``` [๐Ÿ“– Full API Documentation](./docs/api.md) ## ๐Ÿงช Testing ```tsx import { render, screen } from '@testing-library/react' import { Button } from 'keypix-ui' test('renders button with text', () => { render(<Button>Click me</Button>) expect(screen.getByRole('button', { name: /click me/i })).toBeInTheDocument() }) test('handles click events', () => { const handleClick = jest.fn() render(<Button onClick={handleClick}>Click me</Button>) fireEvent.click(screen.getByRole('button')) expect(handleClick).toHaveBeenCalledTimes(1) }) ``` ## ๐Ÿ“Š Performance - **Bundle Size**: 13.47 KB gzipped - **Loading Time**: 264ms on slow 3G - **Runtime**: 94ms on Snapdragon 410 - **Tree Shaking**: Fully supported - **Code Splitting**: Automatic ## ๐Ÿ› ๏ธ Development ### Prerequisites - Node.js 18+ - npm/yarn/pnpm ### Setup ```bash git clone https://github.com/keypix-tech/ui.git cd keypix-ui npm install ``` ### Scripts ```bash # Development npm run dev # Start development server with demo # Building npm run build # Build library npm run build:clean # Clean build # Testing npm run test # Run tests npm run test:watch # Watch mode npm run test:coverage # Coverage report # Quality npm run lint # ESLint npm run type-check # TypeScript check npm run size # Bundle size analysis ``` ### Contributing 1. Fork the repository 2. Create a feature branch 3. Make your changes 4. Add tests 5. Submit a pull request [๐Ÿ“‹ Contributing Guidelines](./CONTRIBUTING.md) ## ๐Ÿ“ˆ Roadmap - [ ] **More Components** - [ ] DataGrid - [ ] DatePicker - [ ] MultiSelect - [ ] FileUpload - [ ] RichTextEditor - [ ] **Enhanced Features** - [ ] Animation library - [ ] Form validation - [ ] Internationalization - [ ] Server-side rendering - [ ] **Developer Experience** - [ ] CLI tool - [ ] VS Code extension - [ ] Figma plugin - [ ] Design tokens - [ ] **Documentation** - [ ] Interactive playground - [ ] Video tutorials - [ ] Migration guides - [ ] Best practices ## ๐Ÿค Community - [๐Ÿ“– Documentation](https://ui.keypix.uz/docs) - [๐ŸŽจ Live Demo](#live-demo) - [๐Ÿ› Issues](https://github.com/keypix-tech/ui/issues) - [๐Ÿ’ฌ Discussions](https://github.com/keypix-tech/ui/discussions) - [๐Ÿ“ง Email](mailto:keypixteam@gmail.com) ## ๐Ÿ“„ License MIT License - see the [LICENSE](LICENSE) file for details. ## ๐Ÿ™ Acknowledgments - [Tailwind CSS](https://tailwindcss.com/) for the utility-first approach - [shadcn/ui](https://ui.shadcn.com/) for inspiration - [Radix UI](https://www.radix-ui.com/) for accessibility patterns - [React](https://reactjs.org/) for the amazing framework --- <div align="center"> **Made with โค๏ธ by [Keypix Team](https://keypix.uz)** [Website](https://ui.keypix.uz) โ€ข [GitHub](https://github.com/keypix-tech/ui) โ€ข [Twitter](https://twitter.com/keypixtech) </div>