Overview
Relevant source files This document introduces@ui8kit/core, a minimalist React UI component library built on utility-first Tailwind CSS and semantic HTML5. It covers the design philosophy, architectural layers, component inventory, variant system, and integration methods.
For installation instructions and setup, see Getting Started.For detailed architectural descriptions, see Architecture.
For complete API documentation, see API Reference. Sources: .devin/wiki.json24-33 README.md1-10
Purpose and Scope
@ui8kit/core is a production-ready React component library designed to enable rapid interface development with minimal code. The library provides 23 total components organized in three architectural layers, styled through 12 composable CVA-based variants that eliminate the need for manual className management in ~80% of use cases.
Target Audience: React developers building applications with Tailwind CSS who prioritize:
- Minimal bundle size and code footprint
- Type-safe component APIs with TypeScript
- Semantic HTML5 for accessibility and SEO
- Flexible composition patterns without rigid design constraints
- 5 core primitive components (Layer 1) for foundational layouts
- 15 UI composite components (Layer 2) for common interface patterns
- 3 layout template components (Layer 3) for application structures
- 12 reusable variant categories covering spacing, colors, layout, typography, and effects
- Multiple integration methods: NPM package, per-component installation, git submodule, direct source
- Opinionated design system with fixed visual style
- Form validation or state management
- Animation framework
- Icon library (depends on
lucide-reactfor icons in specific components)
Design Philosophy
The library is built on the principle of minimal code with maximum flexibility. Complex interfaces emerge from composing a small set of primitives rather than assembling dozens of specialized components.Core Principles
| Principle | Implementation | Benefit |
|---|---|---|
| Minimalism | 15 UI components vs. 50+ in typical libraries | Reduced bundle size, faster learning curve |
| 80/20 Coverage | 12 variants cover ~80% of styling needs | Eliminates most manual className usage |
| Composability | Primitives combine to create unlimited designs | No rigid design constraints |
| Type Safety | Full TypeScript support with prop interfaces | Prevents runtime prop errors |
| Semantic HTML | Components render as <section>, <article>, <nav>, etc. | Better accessibility and SEO |
| Zero Runtime Overhead | CVA generates static Tailwind classes at build time | No runtime style calculation |
Minimalism in Practice
The library achieves interface complexity through composition rather than component proliferation:- Eliminates 4 specialized components from the bundle
- Provides full styling control through variants
- Maintains semantic HTML with
component="form"andcomponent="input" - Requires no additional component learning curve
Component Architecture
Layer 1: Core Primitives (src/core/ui/)
Five foundational components that directly apply the variant system:
| Component | File | Purpose | Variants Applied |
|---|---|---|---|
Block | Block.tsx | Semantic container (section, article, nav, etc.) | All 12 variants |
Box | Box.tsx | Generic flexible primitive (any HTML element) | All 12 variants |
Grid | Grid.tsx | CSS Grid layout with cols and rows props | Spacing, layout variants |
Flex | Flex.tsx | Flexbox layout with direction and justify props | Spacing, layout variants |
Stack | Stack.tsx | Vertical/horizontal stacking with gap prop | Spacing variants |
Layer 2: UI Components (src/components/ui/)
Fifteen composite components that extend primitives through prop forwarding:
| Component | File | Base Primitive | Special Features |
|---|---|---|---|
Button | button.tsx | Box | variant, size, leftSection, rightSection |
Card | card.tsx | Block | Compound: Card.Header, Card.Content, Card.Footer |
Text | text.tsx | Box | Semantic tags: p, span, em, strong |
Title | title.tsx | Box | Heading hierarchy: h1-h6 via order prop |
Badge | badge.tsx | Box | Small label with variant |
Icon | icon.tsx | Box | SVG wrapper with size control |
Image | image.tsx | Box | Optimized with alt and loading props |
Container | container.tsx | Block | Responsive max-width: sm, md, lg, xl, 2xl |
Group | group.tsx | Flex | Element grouping with gap |
Sheet | sheet.tsx | N/A | Drawer with side prop (uses lucide-react) |
Accordion | accordion.tsx | N/A | Expandable sections (uses lucide-react) |
Layer 3: Layout Templates (src/layouts/)
Three template components that orchestrate Layer 2 components into application structures:
| Component | File | Purpose | Dependencies |
|---|---|---|---|
DashLayout | DashLayout.tsx | Dashboard with resizable sidebar, header, content | react-resizable-panels |
LayoutBlock | LayoutBlock.tsx | Content section with beforeContent/content/afterContent hooks | Grid |
SplitBlock | SplitBlock.tsx | Two-column layout (media + content or content + media) | Container |
Variant System Overview
className management in most scenarios.
Variant Categories
| Category | Props | Values | File |
|---|---|---|---|
| Spacing | p, m, px, py, pt, pb, pl, pr, mx, my, mt, mb, ml, mr | none, xs, sm, md, lg, xl, 2xl, auto | spacing-variants.ts |
| Colors | bg, c, borderColor | Design system colors: primary, secondary, destructive, card, foreground, etc. | color-variants.ts |
| Layout | w, h, minH, maxW, position | auto, full, screen, fit, min, max | layout-variants.ts |
| Typography | size, weight, align, leading | Font sizes: xs, sm, md, lg, xl, 2xl, 3xl; weights: normal, medium, bold | typography-variants.ts |
| Effects | rounded, shadow, border | Corner radius, shadow depth, border styles | effect-variants.ts |
| Flexbox | direction, justify, items, wrap, gap | Flexbox properties | Integrated in layout variants |
| Grid | cols, rows, gap | CSS Grid properties | Integrated in layout variants |
Variant Application Flow
- Developer writes variant props in JSX:
<Card p="lg" rounded="xl" shadow="md" bg="card" /> - CVA engine resolves props to Tailwind classes via
cva()function fromclass-variance-authority - Generated classes output:
p-8 rounded-xl shadow-md bg-card - Whitelist validation ensures Tailwind purge doesn’t remove necessary classes (618 classes in
core-classes.json) - DOM renders with final class string applied
Build-Time Class Extraction
Thescripts/cva-extractor.ts script scans all variant files and generates src/lib/core-classes.json:
- Tailwind safelist - prevents CSS purge from removing variant classes
- tw-merge safety - ensures class merging works correctly
Technology Stack
Core Dependencies
| Package | Version | Purpose | Usage |
|---|---|---|---|
react | ^18.0.0 or ^19.0.0 | UI framework | Peer dependency (provided by consumer) |
react-dom | ^18.0.0 or ^19.0.0 | React rendering | Peer dependency (provided by consumer) |
class-variance-authority | ^0.7.1 | Variant engine | Powers the 12 variant categories |
clsx | ^2.1.1 | Class concatenation | Utility for merging class strings |
tailwind-merge | ^3.3.1 | Class deduplication | Prevents duplicate Tailwind classes |
lucide-react | ^0.525.0 | Icon library | Used in Sheet and Accordion components |
react-resizable-panels | ^3.0.6 | Resizable layouts | Used in DashLayout for sidebar resizing |
Build Tools
| Tool | Purpose | Configuration |
|---|---|---|
| TypeScript | Type checking and compilation | tsconfig.json with ES2022 target |
| ESLint | Code quality | .eslintrc with TypeScript rules |
| Bun | Package manager and runtime | bun-types for TypeScript support |
cva-extractor.ts | Build-time class extraction | Generates core-classes.json whitelist |
buildy-ui CLI | Component registry scanner | Generates registry.json metadata |
Distribution Format
The library distributes as ES2022 modules with TypeScript declarations:| Artifact | Path | Purpose |
|---|---|---|
| Main entry | dist/index.js | ES2022 module exports |
| Type definitions | dist/index.d.ts | TypeScript interface declarations |
| Class whitelist | src/lib/core-classes.json | Tailwind safelist (618 classes) |
| Component registry | src/registry.json | Metadata for per-component installation |
Integration Methods
Method 1: Full Library Installation (NPM)
Use Case: Standard application development with all components available- Single dependency declaration
- All components immediately available
- Automatic updates via
npm update
Method 2: Per-Component Installation (buildy-ui CLI)
Use Case: Bundle optimization, progressive adoption, microservicescomponents/ui/ directory
- Minimal bundle size (only installed components)
- No dependency on full library
- Full source code control
Method 3: Git Submodule (Monorepo)
Use Case: Monorepo architectures, shared component libraries across projects- Direct source access
- Version pinning via git commits
- Shared across monorepo packages
- Local modifications possible
Method 4: Direct Source Integration
Use Case: Custom builds, heavily modified components, embedded systems Process:- Copy
src/directory to project - Adjust import paths
- Customize components as needed
- Build with project’s TypeScript compiler
- Complete control over source code
- No external dependencies
- Custom compilation targets
- Remove unused components
Method 5: Programmatic Registry Access
Use Case: Build tooling, component documentation generators, automated testing- Automate component discovery
- Generate documentation
- Build custom CLI tools
- Validate component metadata
Component Inventory
Complete Component List
| Layer | Component Count | Components |
|---|---|---|
| Layer 1: Core Primitives | 5 | Block, Box, Grid, Flex, Stack |
| Layer 2: UI Components | 15 | Button, Card, Text, Title, Container, Icon, Image, Badge, Group, Sheet, Accordion |
| Layer 3: Layouts | 3 | DashLayout, LayoutBlock, SplitBlock |
| Total | 23 | - |
Component Distribution by Type
| Category | Count | Purpose |
|---|---|---|
| Primitives | 5 | Foundation for all layouts and components |
| Content | 5 | Text, titles, images, icons, badges |
| Containers | 3 | Cards, groups, containers |
| Interactive | 2 | Buttons, sheets |
| Collapsible | 1 | Accordion |
| Layouts | 7 | Grid, Flex, Stack, DashLayout, LayoutBlock, SplitBlock, Container |
Variant Coverage Statistics
| Coverage Area | Percentage | Variants Involved |
|---|---|---|
| Spacing | 30% | 16 props (p, m, px, py, etc.) |
| Colors | 20% | 3 props (bg, c, borderColor) |
| Layout | 20% | 5 props (w, h, minH, maxW, position) |
| Typography | 15% | 4 props (size, weight, align, leading) |
| Effects | 15% | 3 props (rounded, shadow, border) |
| Total Coverage | ~80% | 12 variant categories |
Key Features Summary
Type Safety and Developer Experience
| Feature | Implementation | Benefit |
|---|---|---|
| Full TypeScript Support | All components with precise prop interfaces | Prevents runtime errors, IDE autocomplete |
| Prop Forwarding | Extended components inherit base props | Consistent API, reduced learning curve |
| Semantic HTML | Components render as section, article, nav, etc. | Better accessibility (WCAG), improved SEO |
| Data Attributes | All components include data-class attribute | Consistent DOM targeting for testing/styling |
| ForwardRef Pattern | All components support ref forwarding | Direct DOM access when needed |
Performance and Bundle Size
| Optimization | Implementation | Benefit |
|---|---|---|
| Zero Runtime Overhead | CVA generates static classes at build time | No style calculation at runtime |
| Tree Shaking | ES2022 modules with sideEffects: false | Unused components removed by bundlers |
| Minimal Dependencies | Only 5 core dependencies | Smaller bundle size |
| Class Whitelist | 618 classes in core-classes.json | Tailwind purge safety |
| Per-Component Install | Via buildy-ui add command | Install only what you need |
Design Flexibility
| Capability | Implementation | Benefit |
|---|---|---|
| Composable Architecture | Primitives combine into unlimited designs | No rigid design constraints |
| Variant System | 12 reusable categories | ~80% of styling without className |
| Compound Components | Card.Header, Card.Content, Card.Footer | Flexible composition patterns |
| Dark Mode | ThemeProvider with persistence | Built-in theme support |
| Responsive Design | Tailwind responsive prefixes work on all variants | Mobile-first layouts |
Getting Started
To begin using@ui8kit/core, proceed to Getting Started for installation instructions and basic configuration examples.
For detailed architectural documentation, see Architecture.For component API reference, see API Reference.
For development patterns and best practices, see Development Guide. Sources: .devin/wiki.json35-43 README.md21-60