Getting Started
Relevant source files This document covers the installation, configuration, and initial setup of@ui8kit/core in your React application. It provides step-by-step instructions for integrating the library into different project types (Next.js, Vite, Create React App) and demonstrates basic component usage patterns.
For detailed architectural information, see Architecture. For complete component API documentation, see API Reference. For advanced integration patterns including monorepo setup, refer to SUBMODULE_GUIDE.md
Prerequisites
Before installing@ui8kit/core, ensure your development environment meets these requirements:
| Requirement | Version | Purpose |
|---|---|---|
| Node.js | 18.0.0+ | JavaScript runtime |
| React | 18.0.0 or 19.0.0+ | Peer dependency |
| React DOM | 18.0.0 or 19.0.0+ | Peer dependency |
| Tailwind CSS | 3.4.0+ | Utility-first styling |
| TypeScript | 5.0.0+ (optional) | Type safety |
Installation Methods
The library supports multiple installation approaches to accommodate different project architectures and optimization requirements.Installation Flow
Method 1: Full Library Installation (Recommended)
Install the complete library with all 15 UI components and 3 layout templates:- Core primitives:
Block,Box,Grid,Flex,Stack - UI components:
Button,Card,Text,Title,Container,Icon,Image,Badge,Group,Sheet,Accordion - Layout components:
DashLayout,LayoutBlock,SplitBlock - CVA variant system and theme utilities
Method 2: Per-Component Installation
Install individual components for optimal bundle size:- UI components →
components/ui/ - Layout components →
layouts/
Method 3: Monorepo Submodule
For monorepo architectures, integrate as a Git submodule:- Direct source access for customization
- Turbo/workspace integration
- Zero-copy dependency resolution
Project Setup
After installation, configure your project to enable Tailwind CSS utilities, theme variables, and TypeScript path resolution.Setup Steps by File
Step 1: Install Tailwind CSS
If Tailwind CSS is not already installed:tailwind.config.js and postcss.config.js.
Sources: README.md29-34
Step 2: Configure Tailwind
Updatetailwind.config.js to include library component paths and enable dark mode:
contentpaths: Must include library source files to prevent Tailwind from purging necessary classesdarkMode: 'class': Required for theme toggle functionality- CSS variable colors: Enable dynamic theming via
hsl(var(--primary))pattern
Step 3: Setup CSS Variables and Tailwind Layers
Create or update your global CSS file (typicallysrc/index.css or app/globals.css):
- Colors use HSL format without the
hsl()wrapper:"187.4739 173.4032% 31.3580%" - Applied in Tailwind config as:
hsl(var(--primary)) - This pattern enables runtime theme switching
Step 4: Configure TypeScript (Optional)
If using TypeScript, add path aliases totsconfig.json:
Basic Usage
Once configured, you can import and use components with the CVA variant system.Component Import and Usage Pattern
Example 1: First Component
Create a simple card with button using variant props:- Variant props:
p="lg",rounded="xl",shadow="md"instead ofclassName - Compound components:
Card.Header,Card.Content,Card.Footerfor flexible composition - Semantic components:
Text as="h2"renders<h2>element - Stack layout:
Stack gap="md"for vertical spacing
Example 2: Theme Provider Setup
Wrap your application withThemeProvider for dark mode support:
useTheme hook in components:
modernUITheme- Contemporary design systemskyOSTheme- Sky-inspired palettelesseUITheme- Minimal aesthetic
Example 3: Layout Composition
Build a page layout with primitives:- Block: Semantic container (
section,nav,main,article) - Container: Responsive max-width wrapper
- Stack: Vertical layout with gap
- Grid: CSS Grid with column control
- Box: Generic div with variant props
Framework-Specific Setup
Next.js Integration
App Router (Next.js 13+)
1. Install dependencies:app/layout.tsx:
suppressHydrationWarning to <html> to prevent theme class mismatch warnings during hydration.
3. Update app/globals.css:
Import Tailwind layers and CSS variables as shown in Step 3
4. Configure tailwind.config.js:
Pages Router (Next.js 12 and earlier)
Configurepages/_app.tsx:
Vite Integration
1. Create Vite React project:vite.config.ts:
src/main.tsx:
src/App.tsx:
Create React App Integration
1. Create CRA project:tailwind.config.js:
src/index.tsx:
src/App.tsx:
Verification
After setup, verify your installation with this checklist:Verification Checklist
| Check | Expected Behavior | Troubleshooting |
|---|---|---|
| Component import | import { Button } from '@ui8kit/core' works without errors | Verify node_modules/@ui8kit/core exists |
| Variant props | <Box p="lg" rounded="md" /> applies classes | Check Tailwind content paths include library |
| Dark mode toggle | Clicking theme toggle switches appearance | Verify darkMode: 'class' in Tailwind config |
| CSS variables | Colors render correctly in light/dark modes | Check :root and .dark variables in CSS |
| TypeScript types | No type errors in IDE | Verify TypeScript version ≥5.0.0 |
| Dev server | Application runs without console errors | Check peer dependencies installed |
Test Component
Create a test component to verify all features:- Card renders with padding, rounded corners, and shadow
- Button changes appearance on hover
- Theme toggle switches between light/dark modes
- Colors update based on CSS variables
- No console errors or warnings
Next Steps
After completing the setup:- Explore Components: Review the UI Components section for detailed component documentation
- Learn Variants: Study the Variant System to understand the 12 reusable variants
- Build Layouts: Explore Layout Components for dashboard and page templates
- Review Patterns: Check Development Guide for common usage patterns
- Implement Dark Mode: See Dark Mode for advanced theming