CSS @when / @else Conditions
Conditional logic inside CSS without media queries or JS
- State-driven styles
- Declarative theming
- Hydration-free UI logic
- Conditional component modes
This article explores the new wave of browser-native features introduced between 2023–2025. These capabilities fundamentally change how UI frameworks can be built: enabling resumability, zero-JS controls, native state handling, accessible components, and server-rendered shadow DOM without hydration. This is the first comprehensive map of modern CSS and HTML features intended specifically for framework authors, design system teams, and engineers building next-generation UI kits.
Over the last two years, browsers have gained an unprecedented set of native capabilities: CSS conditions, @scope, anchor positioning, declarative shadow DOM, customizable select controls, the popover API, and more. These features dramatically reduce the need for JavaScript-driven UI, unlock server-rendered component trees without hydration, and provide primitives that previously required full frameworks. For teams building resumable architectures or buildless UI frameworks, these native features shift fundamental assumptions: many “framework responsibilities” now belong to the browser itself.
Conditional logic inside CSS without media queries or JS
True component-scoped styling without Shadow DOM
Attach UI elements to triggers without manual coordinates
Conditional styling based on child state
Native nested selectors
Explicit ordering of reset/theme/component layers
Native popover lifecycle with escape handling, focus management, and animations
Fully accessible modal behavior built into HTML
Disable entire regions of the DOM without JS logic
Selectable UI with complete styling control
Next-generation layout primitives
Browser-native DOM transitions
Declarative Shadow DOM (DSD) introduces server-rendered shadow roots directly in HTML. Combined with `` and static stylesheets, this unlocks fully styled, encapsulated UI components rendered at the edge without client bootstrapping or hydration. For resumable frameworks, this eliminates the need to reconstruct component trees on the client. State resumes only where needed.
Modern CSS introduces primitives that completely reshape how design tokens, themes, and component states are implemented. With `@property`, `color-mix()`, `relative-color()`, and new color spaces like OKLCH, theme systems can be mathematically defined instead of manually curated.
Typed custom properties enabling safer animations and theme variables
Perceptually uniform color math
Native theming for form controls
Automatic WCAG-aware color selection
With these platform primitives, a modern UI framework can eliminate substantial hydration, client-side rendering, and JS-heavy interaction handling. The browser now covers popovers, dialogs, position logic, scoped styling, color systems, and even conditional state logic. The architectural result is a framework that focuses on: • partial serialization of state • resumable fine-grained interaction • server-rendered component structure • minimal client-side activation
| Old Responsibility | Implemented In | Replaced By |
|---|---|---|
| Dropdown logic | React/Vue/Svelte | Popover API + Anchor Positioning |
| Modal accessibility | Framework components | HTML Dialog + inert |
| Parent/child state styling | JS event/state | :has() + @when |
| Component style scoping | CSS-in-JS | @scope + Cascade Layers |
| Custom select widgets | JS UI libraries | Selectlist + Popover |
| Client state hydration | Framework runtime | Declarative Shadow DOM |
The HTML and CSS platform of 2025 provides the strongest foundation ever for building a resumable, server-native UI framework. With declarative shadow DOM, anchor positioning, CSS conditions, scoped styling, and native popover/dialog controls, many responsibilities once handled by heavyweight frameworks are now built directly into the browser. The next generation of UI frameworks will not compete with the platform—they will build on it. This shift makes room for architectures that are simpler, faster, and fundamentally aligned with how the browser naturally works.
Clear triggers, models, and ROI for bringing in external guidance—augmented responsibly with AI
Read more →A clear criteria-and-evidence framework to choose and evolve your stack—now with AI readiness and TCO modeling
Read more →Make risks quantifiable and investable—evidence, scoring, mitigations, and decision gates
Read more →Ship the technical essentials that actually move SEO for new sites
Read more →Understanding CSR, SSR, SSG, hydration, resumability, and PWAs—and why resumability represents the next efficiency breakthrough
Read more →