UI Components
UI8Kit provides a comprehensive set of composite components that extend base primitives with typed variant props. These components eliminate manual className management while providing full customization through a consistent API.Quick Start
Get started with UI components by importing them from the core package:All UI components support universal props like
p, m, rounded, and shadow through the variant system. See Universal Props for the complete list.Component Overview
UI components are organized into two categories: Layout Components - Structural elements for page composition UI Components - Interactive elements and content containers Each component provides a developer-friendly API that forwards variant props to underlying primitives while adding component-specific functionality.Component Architecture
UI components form the middle layer of UI8Kit’s three-layer architecture:- Foundation Layer: CVA variant functions that generate Tailwind classes
- Primitive Layer: Base HTML elements with minimal styling
- Component Layer: Composite components with typed variant props
Prop Forwarding Pattern
UI components extend primitives through prop forwarding. Each component:- Imports variant functions from
@ui8kit/core - Accepts typed variant props in its interface
- Applies variants using the
cn()utility - Forwards remaining props to the base primitive
This pattern provides type safety while eliminating manual className management. Components like
Badge and Button inherit spacing, color, and visual variants from the foundation layer.Badge Component Example
TheBadge component demonstrates prop forwarding in action:
Variant System
UI components access 12 variant categories from the foundation layer. Each component selectively imports only the variants it needs:How Variants Work
When you use variant props, UI8Kit automatically converts them to Tailwind classes:"inline-flex items-center font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring p-8 rounded-xl shadow-md bg-green-500 text-green-50 ..."
Data Attributes
Each UI component includes stabledata-class attributes for reliable targeting:
Use
data-class attributes for CSS selectors, testing, and DOM queries. These remain stable even when component styles change.TypeScript Support
All UI components provide full TypeScript support with:- Typed variant props with autocomplete
- HTML attribute forwarding for standard DOM props
- Ref forwarding for direct DOM access
- Compound component patterns for complex UI structures
Layout Components
Block
Section wrapper component with full styling control. Perfect for content sections and custom layouts.string
default:"div"
HTML element to render as the container
Container
Responsive container with size presets and centering options.string
default:"md"
Container width preset
boolean
Center the container horizontally
Stack
Vertical flex layout for stacking elements with consistent spacing.string
Spacing between child elements
string
Vertical alignment of children
Group
Horizontal flex layout for arranging elements in a row.string
Spacing between child elements
string
default:"start"
Horizontal distribution of children
Grid
CSS Grid layout with responsive column presets.string
default:"1"
Responsive column configuration
string
Spacing between grid items
Card
Card component with compound structure for headers, content, and footers. Compound Components:Card: Root containerCardHeader: Top sectionCardTitle: HeadingCardDescription: SubtitleCardContent: Main content areaCardFooter: Bottom section
Button
Interactive button with variants, sizes, and loading states.string
default:"default"
Button style variant
string
default:"default"
Button size preset
ReactNode
Content to display on the left side
ReactNode
Content to display on the right side
boolean
Show loading state
Badge
Small status indicators with dots and sections.string
default:"default"
Badge style variant
string
default:"default"
Badge size preset
boolean
Show status indicator dot
ReactNode
Content before the badge text
ReactNode
Content after the badge text
Title
Semantic heading elements with typography control. Key Props:-
order:1|2|3|4|5|6(maps toh1-h6) -
size: Font size variant -
fw: Font weight -
c: Text color - Supports spacing variants
Text
Text elements with full typography control. Key Props:-
size: Font size variant -
c: Text color -
ta: Text alignment ('left'|'center'|'right'|'justify') -
truncate: Boolean for text truncation - Supports spacing variants
Image
Enhanced image component with aspect ratio and fit control. Key Props:-
src,alt: Standard image attributes -
aspect:'square'|'video'|'portrait'|'landscape' -
fit:'contain'|'cover'|'fill'|'none' - Supports rounded and shadow variants
Icon
Icon wrapper for lucide-react icons with size and color control. Key Props:-
lucideIcon: Lucide icon component -
size: Size variant -
c: Color variant - Supports spacing variants
Accordion
Expandable/collapsible sections with state management. Structure:-
Accordion: Root with controlled/uncontrolled state -
AccordionItem: Individual collapsible section -
AccordionTrigger: Clickable header (usesButton) -
AccordionContent: Collapsible content area
-
type:'single'|'multiple' -
collapsible: Boolean for closing active item -
value,onValueChange,defaultValue: State control -
w: Width variant
-
value: Unique identifier (required) -
w: Width variant -
gap,direction: Flex variants
-
Extends all
ButtonProps -
w: Width variant (defaults to'full')
-
w: Width variant - Automatic animation via CSS transitions
Universal Props
All UI components support these universal props through the variant system:Spacing Props
Visual Props
Layout Props
Usage Examples
Basic Components
Compound Components
Layout Patterns
Next Steps
Core Components
Learn about the base primitives that power UI components
Layout Components
Build responsive page layouts with layout components