How It Works

Deep dive into the architecture of Lemon CSS and its unique multi-platform capabilities.

The Proxy Engine

Lemon CSS uses JavaScript Proxy objects to intercept property accesses. When you access Lemon.backgroundColor("primary"), the proxy captures the "backgroundColor" property and the "primary" argument.

// Simplified internal logic
const Lemon = new Proxy({}, {
  get(target, prop) {
    return (value) => ({ [prop]: resolveValue(value) });
  }
});

Web & Mobile Synergy

The core philosophy of Lemon is Write Once, Style Everywhere. Because the output is a plain JavaScript object, it is compatible with both React's style prop (for Web) and React Native's style prop (for Mobile).

Web
<div style={Lemon.padding(16)} />
Mobile
<View style={Lemon.padding(16)} />

Config Resolution

The engine checks your lemon.config.ts for predefined tokens. If a property access matches a config key (like "primary" for colors or "lg" for sizes), it automatically resolves to the configured value.

Config

colors: {
  primary: "#007bff"
}

Result

Lemon.color.primary
// -> { color: "#007bff" }

Zero Runtime CSS

Unlike traditional CSS-in-JS libraries that inject style tags, Lemon generates plain JavaScript objects that are passed directly to the style attribute. This means zero style recalculations and no extra DOM elements.