Problem
Page CSS is currently raw multiline strings with no validation:
const page_css =
\\.card { background: var(--bg2); }
\\.card:hover { opacity: 0.88; }
;
Typos in class names, unused styles, and invalid properties are never caught.
Proposed Solution
A comptime CSS builder that validates at compile time:
const styles = mer.css(.{
.card = .{ .background = "var(--bg2)", .border_radius = "8px" },
.card_hover = .{ .opacity = 0.88 },
.title = .{ .font_size = "clamp(28px, 4vw, 42px)", .font_family = "serif" },
});
// In render:
h.div(.{ .class = styles.card }, .{ ... })
// ^^^ compile error if you reference styles.nonexistent
Benefits:
- Dead style elimination — only emit CSS for classes actually used
- Property validation at comptime (catch
backgroud typos)
- Scoped class names to prevent collisions between pages
- CSS output is a single minified string
Complexity
Medium — Zig's comptime is powerful enough to build this as a library, no compiler changes needed.
Problem
Page CSS is currently raw multiline strings with no validation:
Typos in class names, unused styles, and invalid properties are never caught.
Proposed Solution
A comptime CSS builder that validates at compile time:
Benefits:
backgroudtypos)Complexity
Medium — Zig's comptime is powerful enough to build this as a library, no compiler changes needed.