API Reference
Relevant source files This document provides a comprehensive reference for all exported APIs from the@ui8kit/core library. It covers component exports, variant props, TypeScript interfaces, and naming conventions used throughout the codebase.
For architectural context and component relationships, see Architecture. For detailed API documentation of individual components, see sub-pages: Core Components, UI Components, and Layout Components. For usage patterns and examples, see Development Guide.
Export Structure
The library follows a flat export structure from src/index.ts All components, variants, hooks, and utilities are re-exported from this single entry point for simplified imports.Component Export Catalog
The following table documents all component exports with their source locations and TypeScript interfaces:| Export Name | Type | Source File | Props Interface | Description |
|---|---|---|---|---|
Block | Component | src/core/ui/Block.tsx | BlockProps | Semantic block container with HTML5 element support |
Box | Component | src/core/ui/Box.tsx | BoxProps | Flexible primitive with full variant support |
Grid | Component | src/core/ui/Grid.tsx | GridProps | CSS Grid layout primitive |
Flex | Component | src/core/ui/Flex.tsx | FlexProps | Flexbox layout primitive |
Stack | Component | src/core/ui/Stack.tsx | StackProps | Vertical/horizontal stacking with gap |
Button | Component | src/components/ui/Button.tsx | BaseButtonProps | Action button with variants |
Card | Component | src/components/ui/Card.tsx | CardProps | Flexible card with compound parts |
Card.Header | Component | src/components/ui/Card.tsx | CardHeaderProps | Card header section |
Card.Content | Component | src/components/ui/Card.tsx | CardContentProps | Card content section |
Card.Footer | Component | src/components/ui/Card.tsx | CardFooterProps | Card footer section |
Card.Title | Component | src/components/ui/Card.tsx | CardTitleProps | Card title element |
Card.Description | Component | src/components/ui/Card.tsx | CardDescriptionProps | Card description text |
Text | Component | src/components/ui/Text.tsx | TextProps | Semantic text rendering |
Title | Component | src/components/ui/Title.tsx | TitleProps | Heading hierarchy (h1-h6) |
Badge | Component | src/components/ui/Badge.tsx | BadgeProps | Small label component |
Container | Component | src/components/ui/Container.tsx | ContainerProps | Responsive container |
Icon | Component | src/components/ui/Icon.tsx | IconProps | SVG icon wrapper |
Image | Component | src/components/ui/Image.tsx | ImageProps | Optimized image component |
Group | Component | src/components/ui/Group.tsx | GroupProps | Group related elements |
Sheet | Component | src/components/ui/Sheet.tsx | SheetProps | Drawer/sheet component |
Accordion | Component | src/components/ui/Accordion.tsx | AccordionProps | Expandable content sections |
DashLayout | Component | src/layouts/DashLayout.tsx | DashLayoutProps | Dashboard layout template |
LayoutBlock | Component | src/layouts/LayoutBlock.tsx | LayoutBlockProps | Flexible content block layout |
SplitBlock | Component | src/layouts/SplitBlock.tsx | SplitBlockProps | Two-column split layout |
Variant System API
The variant system provides 12 composable prop categories that apply across all components through the CVA (class-variance-authority) engine. Each variant category maps to specific TypeScript types and Tailwind CSS utility classes.Variant Prop Types
Variant Prop Reference Table
| Variant Category | Props | Valid Values | Export Name | Source File |
|---|---|---|---|---|
| Padding | p, px, py, pt, pb, pl, pr | 'none', 'xs', 'sm', 'md', 'lg', 'xl', '2xl' | paddingVariants | src/core/variants/spacing.ts |
| Margin | m, mx, my, mt, mb, ml, mr | 'none', 'xs', 'sm', 'md', 'lg', 'xl', '2xl', 'auto' | marginVariants | src/core/variants/spacing.ts |
| Background | bg | 'background', 'card', 'primary', 'secondary', 'destructive', 'muted', 'accent' | backgroundColorVariants | src/core/variants/colors.ts |
| Text Color | c | 'foreground', 'primary', 'secondary', 'muted', 'accent', 'destructive' | textColorVariants | src/core/variants/colors.ts |
| Border Color | borderColor | 'border', 'input', 'primary', 'secondary', 'destructive' | borderColorVariants | src/core/variants/colors.ts |
| Width | w | 'auto', 'full', 'screen', 'fit', 'min', 'max' | widthVariants | src/core/variants/layout.ts |
| Height | h, minH | 'auto', 'full', 'screen', 'fit', 'min' | heightVariants | src/core/variants/layout.ts |
| Max Width | maxW | 'xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl', '5xl', '6xl', '7xl', 'full' | maxWidthVariants | src/core/variants/layout.ts |
| Position | position | 'relative', 'absolute', 'fixed', 'sticky' | positionVariants | src/core/variants/layout.ts |
| Font Size | size | 'xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl', '5xl' | fontSizeVariants | src/core/variants/typography.ts |
| Font Weight | weight | 'normal', 'medium', 'semibold', 'bold' | fontWeightVariants | src/core/variants/typography.ts |
| Text Align | align | 'left', 'center', 'right', 'justify' | textAlignVariants | src/core/variants/typography.ts |
| Line Height | leading | 'none', 'tight', 'snug', 'normal', 'relaxed', 'loose' | lineHeightVariants | src/core/variants/typography.ts |
| Rounded | rounded | 'none', 'sm', 'md', 'lg', 'xl', '2xl', 'full' | roundedVariants | src/core/variants/effects.ts |
| Shadow | shadow | 'none', 'sm', 'md', 'lg', 'xl', '2xl' | shadowVariants | src/core/variants/effects.ts |
| Border | border | '1px solid border', '2px solid border', 'default' | borderVariants | src/core/variants/effects.ts |
Prop Forwarding Pattern
Components in the library implement a consistent prop forwarding pattern where composite components extend base primitives with additional variant props. This creates a type-safe inheritance chain.Prop Forwarding Examples
The following examples demonstrate how variant props are forwarded from composite components to their base primitives: Button extends Box:TypeScript Type System
The library provides comprehensive TypeScript support with precise type definitions for all components, variants, and utilities.Core Type Hierarchy
Common Type Patterns
| Pattern | Description | Example Interface | Source |
|---|---|---|---|
| Variant Props | Props extracted from CVA variant definitions using VariantProps<typeof variant> | VariantProps<typeof paddingVariants> | src/core/variants/ |
| Component Prop | Union type allowing semantic HTML element selection | component?: 'section' | 'article' | 'nav' | 'header' | 'footer' | 'aside' | 'main' | 'div' | src/core/ui/Block.tsx |
| As Prop | Union type for polymorphic text rendering | as?: 'p' | 'span' | 'div' | 'em' | 'strong' | 'small' | src/components/ui/Text.tsx |
| Order Prop | Numeric literal type for heading levels | order: 1 | 2 | 3 | 4 | 5 | 6 | src/components/ui/Title.tsx |
| Ref Forwarding | ForwardRefExoticComponent with ComponentPropsWithRef | React.forwardRef<HTMLDivElement, BoxProps> | src/core/ui/Box.tsx |
| Compound Components | Namespace pattern for related component parts | Card.Header, Card.Content, Card.Footer | src/components/ui/Card.tsx |
Common Component Props
All components in the library share a consistent set of base props inherited from React’s HTML attributes and the variant system.Standard React Props
| Prop | Type | Description | Inherited From |
|---|---|---|---|
className | string | Additional CSS classes to merge with generated classes | HTMLAttributes |
style | CSSProperties | Inline styles | HTMLAttributes |
children | ReactNode | Child elements to render | HTMLAttributes |
ref | Ref<HTMLElement> | Ref to underlying DOM element | ComponentPropsWithRef |
data-* | string | Data attributes for DOM targeting | HTMLAttributes |
aria-* | string | Accessibility attributes | HTMLAttributes |
Custom Component Props
| Prop | Type | Default | Description | Availability |
|---|---|---|---|---|
component | 'section' | 'article' | 'nav' | 'header' | 'footer' | 'aside' | 'main' | 'div' | 'div' | Semantic HTML element to render | Block, Grid |
as | 'p' | 'span' | 'div' | 'em' | 'strong' | 'small' | 'p' | Text element type | Text |
order | 1 | 2 | 3 | 4 | 5 | 6 | Required | Heading level | Title |
data-class | string | Component name | Component identifier for DOM targeting | All components |
Theme System API
The theme system provides dark mode support, accessibility preferences, and theme persistence through React Context.Theme Provider
Utility Hooks API
The library exports responsive design utilities for viewport detection and media queries.| Hook | Parameters | Return Type | Description | Source |
|---|---|---|---|---|
useMediaQuery | query: string | boolean | Matches CSS media query | src/lib/hooks/useMediaQuery.ts |
useMobile | None | boolean | Detects mobile viewport (< 768px) | src/lib/hooks/useMobile.ts |
useViewport | None | { width: number, height: number } | Returns current viewport dimensions | src/lib/hooks/useViewport.ts |
Component-Specific Variants
Some components define additional variants beyond the core variant system for specialized styling.Button Variants
Card Variants
Data Attributes
All components render withdata-class attributes for consistent DOM targeting and styling.
| Component | data-class Value | Purpose |
|---|---|---|
Block | 'block' | Identifies Block primitive |
Box | 'box' | Identifies Box primitive |
Grid | 'grid' | Identifies Grid primitive |
Flex | 'flex' | Identifies Flex primitive |
Stack | 'stack' | Identifies Stack primitive |
Button | 'button' | Identifies Button component |
Card | 'card' | Identifies Card component |
Card.Header | 'card-header' | Identifies Card header |
Card.Content | 'card-content' | Identifies Card content |
Card.Footer | 'card-footer' | Identifies Card footer |
Text | 'text' | Identifies Text component |
Title | 'title' | Identifies Title component |
Badge | 'badge' | Identifies Badge component |
Container | 'container' | Identifies Container component |
Detailed API Documentation
For complete API documentation of individual components with all props, methods, and usage examples, see:- Core Components - Primitives:
Block,Box,Grid,Flex,Stack - UI Components - Composite components:
Button,Card,Text,Title,Badge, etc. - Layout Components - Layout templates:
DashLayout,LayoutBlock,SplitBlock