Overview
Dynamic UI is built on a robust micro frontend architecture designed specifically for financial applications. The library provides a modular, context-driven system that enables seamless integration across distributed applications while maintaining consistency and performance.Core Architecture Patterns
Context-Based Configuration
Dynamic UI uses React Context to provide centralized configuration across all components in your application. The architecture is built around two primary contexts:DContext Provider
TheDContext serves as the main configuration hub for the entire component library:
src/contexts/DContext.tsx
The context provider automatically reads CSS variables for responsive breakpoints using the
getCssVariable utility, syncing your JavaScript logic with SCSS design tokens.- language: Internationalization locale (default:
'en') - currency: Financial formatting configuration with symbol, precision, and separators
- icon: Icon library integration settings (supports Bootstrap Icons, Lucide, etc.)
- breakpoints: Responsive breakpoints automatically synced from CSS variables
- portalName: Portal container identifier for modals and overlays
Portal Architecture
TheDPortalContext manages modal layers, overlays, and floating UI elements using a stack-based architecture:
src/contexts/DPortalContext.tsx
- Stack-based layer management for nested modals
- Automatic body scroll locking when portals are active
- Keyboard trap for accessibility (Tab cycling within active portal)
- Backdrop click handling with configurable dismissal
- Framer Motion animations for smooth transitions
Hook-Based Utilities
Dynamic UI provides specialized hooks for common patterns:usePortal
Creates and manages DOM portal containers dynamically
useStackState
Manages stack-based state for portal layers
useMediaBreakpointUp
Responsive utilities matching SCSS breakpoint system
useDisableBodyScrollEffect
Prevents body scroll when overlays are active
Component Structure
All components follow a consistent architecture pattern:File Organization
Component Props Pattern
Components extend standard HTML attributes while adding custom functionality:- Full TypeScript type safety
- Native HTML attribute support
- Consistent prop interfaces across components
- Extensibility for custom implementations
Micro Frontend Integration
Independent Deployment
Dynamic UI is designed for micro frontend architectures where different teams manage separate applications:Portal Communication
For cross-micro-frontend communication, use the portal system:Bootstrap Foundation
Dynamic UI is built on top of Bootstrap 5.3.8, extending its capabilities for financial applications:- CSS Variable System: All components use CSS custom properties (src/style/root/_root.scss:355)
- Utility Classes: Bootstrap utilities enhanced with financial-specific helpers
- Grid System: Responsive layout system with configurable breakpoints
- Component Prefix: Uses
bs-prefix for Bootstrap compatibility (src/components/config.ts:1)
State Management
Components manage internal state using React hooks while exposing controlled and uncontrolled modes:Performance Considerations
Tree Shaking
Tree Shaking
The library is built with Rollup to support tree shaking. Import only the components you need:
CSS Optimization
CSS Optimization
SCSS is compiled separately, allowing you to:
- Import only required component styles
- Override variables before compilation
- Use PostCSS for autoprefixing and minification
Lazy Loading
Lazy Loading
Portal components can be lazy loaded:
Next Steps
Theming System
Learn how to customize colors, typography, and design tokens
Accessibility
Understand built-in accessibility features and WCAG compliance