Skip to main content

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.
Utility Hooks

Theme System

Variant Exports

Layout Components

UI Components

Core Primitives

Package Entry Point

src/index.ts
Main export barrel

Block
BlockProps

Box
BoxProps

Grid
GridProps

Flex
FlexProps

Stack
StackProps

Button
BaseButtonProps

Card + Card.Header/Content/Footer
CardProps, CardHeaderProps

Text
TextProps

Title
TitleProps

Badge
BadgeProps

Container
ContainerProps

Icon
IconProps

Image
ImageProps

Group
GroupProps

Sheet
SheetProps

Accordion
AccordionProps

DashLayout
DashLayoutProps

LayoutBlock
LayoutBlockProps

SplitBlock
SplitBlockProps

spacingVariants
marginVariants, paddingVariants

backgroundColorVariants
textColorVariants, borderColorVariants

widthVariants, heightVariants
positionVariants

fontSizeVariants, fontWeightVariants
textAlignVariants, lineHeightVariants

roundedVariants, shadowVariants
borderVariants

ThemeProvider
ThemeProviderProps

useTheme()
ThemeContextValue

modernUITheme
ThemeConfig

useMediaQuery(query)
boolean

useMobile()
boolean

useViewport()
ViewportSize
Sources: src/index.ts README.md362-386 .devin/wiki.json136-139

Component Export Catalog

The following table documents all component exports with their source locations and TypeScript interfaces:
Export NameTypeSource FileProps InterfaceDescription
BlockComponentsrc/core/ui/Block.tsxBlockPropsSemantic block container with HTML5 element support
BoxComponentsrc/core/ui/Box.tsxBoxPropsFlexible primitive with full variant support
GridComponentsrc/core/ui/Grid.tsxGridPropsCSS Grid layout primitive
FlexComponentsrc/core/ui/Flex.tsxFlexPropsFlexbox layout primitive
StackComponentsrc/core/ui/Stack.tsxStackPropsVertical/horizontal stacking with gap
ButtonComponentsrc/components/ui/Button.tsxBaseButtonPropsAction button with variants
CardComponentsrc/components/ui/Card.tsxCardPropsFlexible card with compound parts
Card.HeaderComponentsrc/components/ui/Card.tsxCardHeaderPropsCard header section
Card.ContentComponentsrc/components/ui/Card.tsxCardContentPropsCard content section
Card.FooterComponentsrc/components/ui/Card.tsxCardFooterPropsCard footer section
Card.TitleComponentsrc/components/ui/Card.tsxCardTitlePropsCard title element
Card.DescriptionComponentsrc/components/ui/Card.tsxCardDescriptionPropsCard description text
TextComponentsrc/components/ui/Text.tsxTextPropsSemantic text rendering
TitleComponentsrc/components/ui/Title.tsxTitlePropsHeading hierarchy (h1-h6)
BadgeComponentsrc/components/ui/Badge.tsxBadgePropsSmall label component
ContainerComponentsrc/components/ui/Container.tsxContainerPropsResponsive container
IconComponentsrc/components/ui/Icon.tsxIconPropsSVG icon wrapper
ImageComponentsrc/components/ui/Image.tsxImagePropsOptimized image component
GroupComponentsrc/components/ui/Group.tsxGroupPropsGroup related elements
SheetComponentsrc/components/ui/Sheet.tsxSheetPropsDrawer/sheet component
AccordionComponentsrc/components/ui/Accordion.tsxAccordionPropsExpandable content sections
DashLayoutComponentsrc/layouts/DashLayout.tsxDashLayoutPropsDashboard layout template
LayoutBlockComponentsrc/layouts/LayoutBlock.tsxLayoutBlockPropsFlexible content block layout
SplitBlockComponentsrc/layouts/SplitBlock.tsxSplitBlockPropsTwo-column split layout
Sources: src/index.ts README.md362-386 src/registry.json2-244

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

Source Files

Effects Variants

Typography Variants

Layout Variants

Color Variants

Spacing Variants

defined in

defined in

defined in

defined in

defined in

defined in

defined in

defined in

defined in

defined in

defined in

defined in

defined in

defined in

defined in

defined in

p, px, py, pt, pb, pl, pr
Type: 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl'

m, mx, my, mt, mb, ml, mr
Type: 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | 'auto'

bg
Type: 'background' | 'card' | 'primary' | 'secondary' | etc.

c
Type: 'foreground' | 'primary' | 'secondary' | 'muted' | etc.

borderColor
Type: 'border' | 'input' | 'primary' | etc.

w
Type: 'auto' | 'full' | 'screen' | 'fit' | 'min' | 'max'

h, minH
Type: 'auto' | 'full' | 'screen' | 'fit' | 'min'

maxW
Type: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | etc.

position
Type: 'relative' | 'absolute' | 'fixed' | 'sticky'

size
Type: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | etc.

weight
Type: 'normal' | 'medium' | 'semibold' | 'bold'

align
Type: 'left' | 'center' | 'right' | 'justify'

leading
Type: 'none' | 'tight' | 'snug' | 'normal' | 'relaxed' | 'loose'

rounded
Type: 'none' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | 'full'

shadow
Type: 'none' | 'sm' | 'md' | 'lg' | 'xl' | '2xl'

border
Type: '1px solid border' | '2px solid border' | etc.

src/core/variants/spacing.ts
paddingVariants, marginVariants

src/core/variants/colors.ts
backgroundColorVariants, textColorVariants

src/core/variants/layout.ts
widthVariants, heightVariants, positionVariants

src/core/variants/typography.ts
fontSizeVariants, fontWeightVariants

src/core/variants/effects.ts
roundedVariants, shadowVariants, borderVariants
Sources: src/core/variants/ README.md170-217 .devin/wiki.json19-22

Variant Prop Reference Table

Variant CategoryPropsValid ValuesExport NameSource File
Paddingp, px, py, pt, pb, pl, pr'none', 'xs', 'sm', 'md', 'lg', 'xl', '2xl'paddingVariantssrc/core/variants/spacing.ts
Marginm, mx, my, mt, mb, ml, mr'none', 'xs', 'sm', 'md', 'lg', 'xl', '2xl', 'auto'marginVariantssrc/core/variants/spacing.ts
Backgroundbg'background', 'card', 'primary', 'secondary', 'destructive', 'muted', 'accent'backgroundColorVariantssrc/core/variants/colors.ts
Text Colorc'foreground', 'primary', 'secondary', 'muted', 'accent', 'destructive'textColorVariantssrc/core/variants/colors.ts
Border ColorborderColor'border', 'input', 'primary', 'secondary', 'destructive'borderColorVariantssrc/core/variants/colors.ts
Widthw'auto', 'full', 'screen', 'fit', 'min', 'max'widthVariantssrc/core/variants/layout.ts
Heighth, minH'auto', 'full', 'screen', 'fit', 'min'heightVariantssrc/core/variants/layout.ts
Max WidthmaxW'xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl', '5xl', '6xl', '7xl', 'full'maxWidthVariantssrc/core/variants/layout.ts
Positionposition'relative', 'absolute', 'fixed', 'sticky'positionVariantssrc/core/variants/layout.ts
Font Sizesize'xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl', '5xl'fontSizeVariantssrc/core/variants/typography.ts
Font Weightweight'normal', 'medium', 'semibold', 'bold'fontWeightVariantssrc/core/variants/typography.ts
Text Alignalign'left', 'center', 'right', 'justify'textAlignVariantssrc/core/variants/typography.ts
Line Heightleading'none', 'tight', 'snug', 'normal', 'relaxed', 'loose'lineHeightVariantssrc/core/variants/typography.ts
Roundedrounded'none', 'sm', 'md', 'lg', 'xl', '2xl', 'full'roundedVariantssrc/core/variants/effects.ts
Shadowshadow'none', 'sm', 'md', 'lg', 'xl', '2xl'shadowVariantssrc/core/variants/effects.ts
Borderborder'1px solid border', '2px solid border', 'default'borderVariantssrc/core/variants/effects.ts
Sources: src/core/variants/ README.md174-217 .devin/wiki.json19-22

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.
Output

Variant Resolution

Primitive Layer

Component Layer

Developer API

forwards spacing & effects

applies button variants

applies base variants

  p='md'
  rounded='lg'
  variant='primary'
  size='md'
/>

Button
src/components/ui/Button.tsx

BaseButtonProps extends
- ButtonHTMLAttributes
- Spacing variants
- Effects variants
- Custom: variant, size

Box
src/core/ui/Box.tsx

BoxProps extends
- HTMLAttributes
- All variant props
- component prop

CVA Engine
class-variance-authority

Generated classes:
'p-4 rounded-lg'
+ button-specific classes

  class='...'
  data-class='button'
/>
Sources: src/components/ui/Button.tsx src/core/ui/Box.tsx .devin/wiki.json11-14 README.md14-17

Prop Forwarding Examples

The following examples demonstrate how variant props are forwarded from composite components to their base primitives: Button extends Box:
// Button receives spacing and effects variants from Box
<Button 
  p="md"           // forwarded to Box → paddingVariants
  rounded="lg"     // forwarded to Box → roundedVariants
  variant="primary" // Button-specific prop
  size="md"        // Button-specific prop
/>
Card extends Block:
// Card receives all Block variants
<Card 
  p="xl"           // forwarded to Block → paddingVariants
  shadow="md"      // forwarded to Block → shadowVariants
  rounded="2xl"    // forwarded to Block → roundedVariants
  bg="card"        // forwarded to Block → backgroundColorVariants
/>
Text extends Box:
// Text receives Box variants plus typography variants
<Text 
  size="lg"        // Text-specific typography variant
  weight="bold"    // Text-specific typography variant
  c="primary"      // forwarded to Box → textColorVariants
  mb="md"          // forwarded to Box → marginVariants
/>
Sources: src/components/ui/Button.tsx src/components/ui/Card.tsx src/components/ui/Text.tsx README.md38-60

TypeScript Type System

The library provides comprehensive TypeScript support with precise type definitions for all components, variants, and utilities.

Core Type Hierarchy

Layout Component Props

UI Component Props

Core Component Props

Variant Types

Base Types

React.HTMLAttributes

React.ComponentPropsWithRef

React.ForwardRefExoticComponent

SpacingProps
from paddingVariants, marginVariants
VariantProps

ColorProps
from backgroundColorVariants, textColorVariants
VariantProps

LayoutProps
from widthVariants, heightVariants
VariantProps

TypographyProps
from fontSizeVariants, fontWeightVariants
VariantProps

EffectsProps
from roundedVariants, shadowVariants
VariantProps

BoxProps extends
HTMLAttributes & SpacingProps
& ColorProps & LayoutProps
& EffectsProps & TypographyProps

BlockProps extends
BoxProps & { component?: 'section' | 'article' | ... }

GridProps extends
BlockProps & { cols?: number, gap?: string }

FlexProps extends
BoxProps & { direction?: 'row' | 'column' }

StackProps extends
BoxProps & { gap?: string, direction?: 'vertical' | 'horizontal' }

BaseButtonProps extends
ButtonHTMLAttributes & SpacingProps
& EffectsProps & { variant, size, ... }

CardProps extends
BlockProps & { variant?: string }

TextProps extends
BoxProps & TypographyProps
& { as?: 'p' | 'span' | ... }

TitleProps extends
BoxProps & TypographyProps
& { order: 1 | 2 | 3 | 4 | 5 | 6 }

DashLayoutProps extends
{ sidebar, header, children, ... }

LayoutBlockProps extends
BlockProps & { layout?: 'default' | 'grid' | 'flex' }

SplitBlockProps extends
{ left, right, ratio?, ... }
Sources: src/core/ui/Box.tsx src/core/ui/Block.tsx src/components/ui/Button.tsx src/components/ui/Card.tsx src/layouts/

Common Type Patterns

PatternDescriptionExample InterfaceSource
Variant PropsProps extracted from CVA variant definitions using VariantProps<typeof variant>VariantProps<typeof paddingVariants>src/core/variants/
Component PropUnion type allowing semantic HTML element selectioncomponent?: 'section' | 'article' | 'nav' | 'header' | 'footer' | 'aside' | 'main' | 'div'src/core/ui/Block.tsx
As PropUnion type for polymorphic text renderingas?: 'p' | 'span' | 'div' | 'em' | 'strong' | 'small'src/components/ui/Text.tsx
Order PropNumeric literal type for heading levelsorder: 1 | 2 | 3 | 4 | 5 | 6src/components/ui/Title.tsx
Ref ForwardingForwardRefExoticComponent with ComponentPropsWithRefReact.forwardRef<HTMLDivElement, BoxProps>src/core/ui/Box.tsx
Compound ComponentsNamespace pattern for related component partsCard.Header, Card.Content, Card.Footersrc/components/ui/Card.tsx
Sources: src/core/ui/ src/components/ui/ .devin/wiki.json11-14

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

PropTypeDescriptionInherited From
classNamestringAdditional CSS classes to merge with generated classesHTMLAttributes
styleCSSPropertiesInline stylesHTMLAttributes
childrenReactNodeChild elements to renderHTMLAttributes
refRef<HTMLElement>Ref to underlying DOM elementComponentPropsWithRef
data-*stringData attributes for DOM targetingHTMLAttributes
aria-*stringAccessibility attributesHTMLAttributes

Custom Component Props

PropTypeDefaultDescriptionAvailability
component'section' | 'article' | 'nav' | 'header' | 'footer' | 'aside' | 'main' | 'div''div'Semantic HTML element to renderBlock, Grid
as'p' | 'span' | 'div' | 'em' | 'strong' | 'small''p'Text element typeText
order1 | 2 | 3 | 4 | 5 | 6RequiredHeading levelTitle
data-classstringComponent nameComponent identifier for DOM targetingAll components
Sources: src/core/ui/Block.tsx src/components/ui/Text.tsx src/components/ui/Title.tsx .devin/wiki.json11-14

Theme System API

The theme system provides dark mode support, accessibility preferences, and theme persistence through React Context.

Theme Provider

// Export: ThemeProvider
// Interface: ThemeProviderProps
interface ThemeProviderProps {
  theme: ThemeConfig;
  children: ReactNode;
  defaultMode?: 'light' | 'dark' | 'system';
  storageKey?: string;
}

// Export: useTheme
// Returns: ThemeContextValue
interface ThemeContextValue {
  isDarkMode: boolean;
  toggleDarkMode: () => void;
  setDarkMode: (enabled: boolean) => void;
  mode: 'light' | 'dark' | 'system';
  setMode: (mode: 'light' | 'dark' | 'system') => void;
  preferences: ThemePreferences;
  updatePreferences: (preferences: Partial<ThemePreferences>) => void;
}

// Export: modernUITheme
// Type: ThemeConfig
interface ThemeConfig {
  name: string;
  displayName: string;
  description: string;
  author: string;
  version: string;
  colors: ColorScheme;
  typography: TypographyConfig;
  spacing: SpacingConfig;
  effects: EffectsConfig;
}
Sources: src/themes/providers/ThemeProvider.tsx1-109 src/themes/modern-ui.ts README.md219-249

Utility Hooks API

The library exports responsive design utilities for viewport detection and media queries.
HookParametersReturn TypeDescriptionSource
useMediaQueryquery: stringbooleanMatches CSS media querysrc/lib/hooks/useMediaQuery.ts
useMobileNonebooleanDetects mobile viewport (< 768px)src/lib/hooks/useMobile.ts
useViewportNone{ width: number, height: number }Returns current viewport dimensionssrc/lib/hooks/useViewport.ts
Usage Example:
import { useMediaQuery, useMobile, useViewport } from '@ui8kit/core';

function ResponsiveComponent() {
  const isMobile = useMobile();
  const isSmall = useMediaQuery('(max-width: 640px)');
  const { width, height } = useViewport();
  
  return <Box>{isMobile ? 'Mobile' : 'Desktop'}</Box>;
}
Sources: src/lib/hooks/ README.md341-359

Component-Specific Variants

Some components define additional variants beyond the core variant system for specialized styling.

Button Variants

// Defined in: src/components/ui/Button.tsx
export const buttonStyleVariants = cva('', {
  variants: {
    variant: {
      default: 'bg-primary text-primary-foreground hover:bg-primary/90',
      destructive: 'bg-destructive text-destructive-foreground hover:bg-destructive/90',
      outline: 'border border-input bg-background hover:bg-accent',
      secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80',
      ghost: 'hover:bg-accent hover:text-accent-foreground',
      link: 'text-primary underline-offset-4 hover:underline'
    }
  }
});

export const buttonSizeVariants = cva('', {
  variants: {
    size: {
      sm: 'h-8 px-3 text-sm',
      md: 'h-10 px-4 text-base',
      lg: 'h-12 px-6 text-lg',
      icon: 'h-10 w-10'
    }
  }
});
Sources: src/components/ui/Button.tsx README.md284-303

Card Variants

// Defined in: src/components/ui/Card.tsx
export const cardVariants = cva('', {
  variants: {
    variant: {
      default: 'bg-card text-card-foreground',
      outlined: 'border border-border bg-card text-card-foreground'
    }
  }
});
Sources: src/components/ui/Card.tsx README.md125-144

Data Attributes

All components render with data-class attributes for consistent DOM targeting and styling.
Componentdata-class ValuePurpose
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
Usage Example:
// Targeting in tests or stylesheets
const button = document.querySelector('[data-class="button"]');

// CSS targeting
[data-class="card"] {
  /* Custom styles */
}
Sources: src/core/ui/ src/components/ui/ .devin/wiki.json11-14

Detailed API Documentation

For complete API documentation of individual components with all props, methods, and usage examples, see: Sources: .devin/wiki.json135-168 src/index.ts README.md1-453