Skip to main content

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: Sources: package.json55-58 package.json59-66

Installation Methods

The library supports multiple installation approaches to accommodate different project architectures and optimization requirements.

Installation Flow

Sources: README.md21-34 README.md252-276 package.json1-70
Install the complete library with all 15 UI components and 3 layout templates:
This installs:
  • 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
Sources: README.md25-27 package.json31-37

Method 2: Per-Component Installation

Install individual components for optimal bundle size:
This method uses src/registry.json to install only the requested components and their dependencies. Each component is deployed to its target directory:
  • UI components → components/ui/
  • Layout components → layouts/
Sources: README.md260-265 src/registry.json

Method 3: Monorepo Submodule

For monorepo architectures, integrate as a Git submodule:
This approach provides:
  • Direct source access for customization
  • Turbo/workspace integration
  • Zero-copy dependency resolution
Complete monorepo setup instructions are available in SUBMODULE_GUIDE.md1-713 Sources: SUBMODULE_GUIDE.md136-144 SUBMODULE_GUIDE.md594-608

Project Setup

After installation, configure your project to enable Tailwind CSS utilities, theme variables, and TypeScript path resolution.

Setup Steps by File

Sources: SUBMODULE_GUIDE.md332-437 SUBMODULE_GUIDE.md449-589

Step 1: Install Tailwind CSS

If Tailwind CSS is not already installed:
This generates tailwind.config.js and postcss.config.js. Sources: README.md29-34

Step 2: Configure Tailwind

Update tailwind.config.js to include library component paths and enable dark mode:
Critical Configuration:
  • content paths: Must include library source files to prevent Tailwind from purging necessary classes
  • darkMode: 'class': Required for theme toggle functionality
  • CSS variable colors: Enable dynamic theming via hsl(var(--primary)) pattern
Sources: SUBMODULE_GUIDE.md332-437

Step 3: Setup CSS Variables and Tailwind Layers

Create or update your global CSS file (typically src/index.css or app/globals.css):
Variable Format:
  • 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
Sources: SUBMODULE_GUIDE.md449-589

Step 4: Configure TypeScript (Optional)

If using TypeScript, add path aliases to tsconfig.json:
Sources: SUBMODULE_GUIDE.md187-217

Basic Usage

Once configured, you can import and use components with the CVA variant system.

Component Import and Usage Pattern

Sources: README.md36-60 README.md91-103

Example 1: First Component

Create a simple card with button using variant props:
Key Patterns:
  • Variant props: p="lg", rounded="xl", shadow="md" instead of className
  • Compound components: Card.Header, Card.Content, Card.Footer for flexible composition
  • Semantic components: Text as="h2" renders <h2> element
  • Stack layout: Stack gap="md" for vertical spacing
Sources: README.md38-60

Example 2: Theme Provider Setup

Wrap your application with ThemeProvider for dark mode support:
Then use the useTheme hook in components:
Available Themes:
  • modernUITheme - Contemporary design system
  • skyOSTheme - Sky-inspired palette
  • lesseUITheme - Minimal aesthetic
Sources: README.md219-249 SUBMODULE_GUIDE.md277-304

Example 3: Layout Composition

Build a page layout with primitives:
Primitives Used:
  • 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
Sources: README.md81-103

Framework-Specific Setup

Next.js Integration

App Router (Next.js 13+)

1. Install dependencies:
2. Configure app/layout.tsx:
Critical: Add 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:
Sources: SUBMODULE_GUIDE.md277-304

Pages Router (Next.js 12 and earlier)

Configure pages/_app.tsx:
Sources: README.md223-232

Vite Integration

1. Create Vite React project:
2. Install dependencies:
3. Configure vite.config.ts:
4. Update src/main.tsx:
5. Configure src/App.tsx:
Sources: SUBMODULE_GUIDE.md154-184 SUBMODULE_GUIDE.md234-258 SUBMODULE_GUIDE.md260-304

Create React App Integration

1. Create CRA project:
2. Install dependencies:
3. Configure tailwind.config.js:
4. Update src/index.tsx:
5. Configure src/App.tsx:
Sources: README.md412-421

Verification

After setup, verify your installation with this checklist:

Verification Checklist

Sources: README.md21-60 README.md412-421

Test Component

Create a test component to verify all features:
Expected Results:
  • 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
Sources: README.md38-60 README.md236-249 SUBMODULE_GUIDE.md277-304

Next Steps

After completing the setup:
  1. Explore Components: Review the UI Components section for detailed component documentation
  2. Learn Variants: Study the Variant System to understand the 12 reusable variants
  3. Build Layouts: Explore Layout Components for dashboard and page templates
  4. Review Patterns: Check Development Guide for common usage patterns
  5. Implement Dark Mode: See Dark Mode for advanced theming
Sources: README.md1-453 .devin/wiki.json24-44