UI Preset System
1. Context & Overview
The Framework M UI Preset System provides progressive visual skinning across core applications and m-plugins. Applications built on Framework M can adopt complete design systems (e.g., Frappe UI v15, Material Design, Ant Design) by injecting a declarative UIPreset into the root application shell without modifying component markup or Tamagui foundations.
2. Building Block View
Core Components
UIPresetContract (libs/framework-m-ui/src/theme/types.ts): Interface specifying token scale overrides (color,radius,size,space) and theme overrides (light,dark).frappePreset(libs/framework-m-ui/src/theme/presets/frappePreset.ts): Official preset implementing Frappe UI v15 visual metrics (solid black primary buttons#111827, pure black dark mode#121212, 6px border radii).buildMThemeConfig(preset?)(libs/framework-m-ui/src/theme/mThemeConfig.ts): Dynamic Tamagui configuration generator that merges preset overrides over base Framework M design tokens.MProvider(libs/framework-m-ui/src/theme/MProvider.tsx): Root theme container providingTamaguiProviderand auto-supplyingThemeProviderif not present.
3. Design Decisions & Token Invariants
Decision 1: Zero Hardcoded Colors in Components
UI components in @framework-m/ui and @framework-m/desk must never specify literal hex strings (#ffffff, #000000, #8b5cf6), RGB colors, or static fallbacks in JSX style props or CSS definitions.
Decision 2: Dynamic Token Pairs for Contrast Inversion
- Primary background action buttons consume
$primary. - Foreground text and icons inside primary elements consume
$primaryColor(which dynamically flips between#ffffffin Light Mode and#121212in Dark Mode underfrappePreset).
Decision 3: Component Token Mapping Table
| Visual Element | Tamagui Theme Token |
|---|---|
| Primary Action Button Background | $primary |
| Primary Action Button Foreground (Text/Icon) | $primaryColor |
| Page / Shell Background | $background |
| Card / Panel Background | $backgroundSecondary |
| Input Fill | $backgroundSecondary |
| Focus Ring Outer Outline | $focusRing |
| Active Navigation Sidebar Card | $sidebarItemActiveBg |
| Default Text Color | $color |
| Muted Text / Subtitles | $colorMuted |
| Primary Border Lines | $borderColor |