Themes and responsiveness
Compile complete theme sheets and respond to logical viewport dimensions.
On this page
Define immutable tokens
:root {
--surface: #ffffff;
--ink: #262626;
--space: 16px;
}
.panel {
background: var(--surface);
color: var(--ink);
padding: var(--space);
}
These tokens are stylesheet constants. They are not DOM-inherited custom properties. Each compiled sheet resolves its own values; a separate scoped sheet does not read constants from a global sheet. Compose the required token definitions into each sheet before compilation.
Prepare light and dark themes
Compile a complete light sheet and a complete dark sheet. The playground reads global.css and composes dark.css overrides before calling compile_stylesheet in build.rs. At runtime it replaces the shared Stylesheet index without resetting component state.
Use a typed Rust theme service when you need reactive values beyond immutable sheet constants. Do not parse CSS on every frame or handler call.
Add viewport conditions
.panel {
gap: 16px;
}
@media (max-width: 900px) {
.panel {
gap: 8px;
padding: 12px;
}
}
@media (min-width: 1200px) and (min-height: 800px) {
.panel {
width: 720px;
}
}
The supported conditions use min/max width/height in logical pixels, inclusive bounds and and. Nested conditions intersect. Native hosts publish actual logical viewport changes to the coordinator. The framework preserves component state while reevaluating rules.
Container queries, media OR/not/orientation, percentage gaps and browser-complete responsive layout are not supported. Plan a layout that works within the application's tested minimum window dimensions.
The playgrounds use a 900 × 820 minimum content window and show a wide-screen page rail. They do not implement mobile application navigation.