Re: [csswg-drafts] [css-view-transitions-2][css-conditionals] Exposing navigation/route matching (#12594)

The CSS Working Group just discussed `[css-view-transitions-2][css-conditionals] Exposing navigation/route matching`, and agreed to the following:

* `RESOLVED: Start a css-navigation ED`

<details><summary>The full IRC log of that discussion</summary>
&lt;TabAtkins> dbaron: Noam presented this twice before, in Paris and once at a Telcon since<br>
&lt;TabAtkins> dbaron: back to use-cases<br>
&lt;TabAtkins> dbaron: a bunch of what this is about is having styles that are conditional on the currently-active navigation, or current url<br>
&lt;TabAtkins> dbaron: you might be navigating from URL A to B and want styles that depend on that<br>
&lt;TabAtkins> dbaron: a bunch of the use-cases are related to VT (but this isn't VT itself)<br>
&lt;TabAtkins> dbaron: like, if you want to set up a VT between a list and details page<br>
&lt;TabAtkins> dbaron: so you click the item in the list, it expands to the whole page, VT shows the transition<br>
&lt;TabAtkins> dbaron: and potentially the reverse<br>
&lt;noamr> q+<br>
&lt;TabAtkins> dbaron: there are other examples like a loading indicator from one thing to another specific thing<br>
&lt;TabAtkins> dbaron: some times these depend on where you're coming from or where you're going<br>
&lt;TabAtkins> dbaron: it's tempting to focus on the link you activated to try and do this<br>
&lt;TabAtkins> dbaron: what we talked about before was conditional rules, conditional on where you're going to or from. we have a spec draft for that<br>
&lt;emilio> https://wicg.github.io/declarative-partial-updates/css-route-matching<br>
&lt;TabAtkins> dbaron: Morten has prototyped a bunch of this in chromium<br>
&lt;TabAtkins> dbaron: not sure exactly how in sync the prototype and spec are right now<br>
&lt;TabAtkins> dbaron: another piece we'd like to add to this is the ability to have pseudo-classes for links that are related to the nav<br>
&lt;TabAtkins> dbaron: hopefully will have a proposal soon, been back and forth in discussion. more complicated than I thought at first<br>
&lt;noamr> https://wicg.github.io/declarative-partial-updates/css-route-matching/<br>
&lt;TabAtkins> dbaron: we'd previous talked about this "route map syntax" in HTML, for now we've taken it out<br>
&lt;TabAtkins> dbaron: but fo rnow we're prototyping b y putting URLs into the css<br>
&lt;TabAtkins> dbaron: a function represented URL patterns (based on WHATWG spec)<br>
&lt;TabAtkins> dbaron: what I'd like to get to is getting the group to adopt the draft. there might be qs about where to put it<br>
&lt;astearns> q+<br>
&lt;lea> q?<br>
&lt;astearns> ack noamr<br>
&lt;TabAtkins> noamr: wanted to quote something from a VT user<br>
&lt;TabAtkins> noamr: "trying to replace the default cross-fade with directional animations, doing without JS right now is like driving without turn signals"<br>
&lt;TabAtkins> noamr: today a lot of people are just cross fading, or otherwise not doing something that gives orietnation<br>
&lt;TabAtkins> noamr: because they'd need JS to actually do it<br>
&lt;fantasai> Maybe less "driving without turn signals" and more "driving without a steering wheel"...<br>
&lt;lea> q+<br>
&lt;JakeA> q+<br>
&lt;TabAtkins> noamr: we didn't want to discuss all the open issues here, just want to check that this is a valid use-case and we're going in the right direction<br>
&lt;TabAtkins> noamr: to adopt the draft as ED and continue form there<br>
&lt;TabAtkins> astearns: 1, why isn't the JS solution sufficient?<br>
&lt;TabAtkins> noamr: two reasons. first, this is a styling decision. CSS VT is a styling feature.<br>
&lt;TabAtkins> noamr: second, perf wise, we're trying to avoid event-driven JS when we can, especially in perf-sensitive places like first paint after navigation<br>
&lt;kbabbitt> qq+ to comment further on JS<br>
&lt;TabAtkins> noamr: using JS, now we have to run script before we can show anything. if we can set it tup in advance in CSS, no need for that<br>
&lt;TabAtkins> noamr: it's also just kinda hard<br>
&lt;astearns> ack astearns<br>
&lt;TabAtkins> astearns: I just wonder if we want to wait on more author patterns<br>
&lt;TabAtkins> noamr: we've already done that, VTs have been out for two years. this *is* the author feedback about the lack.<br>
&lt;TabAtkins> astearns: my other q was about URL patterns, but your draft answers that<br>
&lt;astearns> ack kbabbitt<br>
&lt;Zakim> kbabbitt, you wanted to react to noamr to comment further on JS<br>
&lt;wendyreid> q+<br>
&lt;TabAtkins> kbabbitt: about JS, less that JS isn't sufficient, it's that the more we can move into the engine the better<br>
&lt;TabAtkins> kbabbitt: some of our perf teams are trying to rip out as much JS as possible<br>
&lt;astearns> ack lea<br>
&lt;TabAtkins> lea: I think this is a problem worth solving, authors always talk about how hard routing is<br>
&lt;TabAtkins> lea: could imagine conditionals in HTML based on the route, use-cases in JS based on the route, etc<br>
&lt;TabAtkins> lea: tho it seems you don't want the indirection of naming your route. simple cases you just want to match a single route. then complex cases with lots of routes that you want to use names<br>
&lt;astearns> q+<br>
&lt;TabAtkins> lea: so it seems useful to have both, names and anonymous<br>
&lt;noamr> q+<br>
&lt;TabAtkins> lea: since there are use-cases for both, and naming global routes needs coord across the platform, might be useful to do anonymous matching in CSS and then solve route-naming on top<br>
&lt;TabAtkins> lea: also, someone mentioned @document before, would be interesting to see lessons<br>
&lt;astearns> ack JakeA<br>
&lt;TabAtkins> JakeA: @document would have predated URLPattern<br>
&lt;JakeA> qq+ I didn't get to my comment<br>
&lt;TabAtkins> emilio: it's not particularly complicated to implement, matching a URL can be expensive, but...<br>
&lt;JakeA> qq+<br>
&lt;TabAtkins> emilio: I think it just never got enough adoption<br>
&lt;JakeA> (I didn't get to my comment)<br>
&lt;TabAtkins> emilio: I removed it because it was causing some compat pain<br>
&lt;TabAtkins> emilio: we still support @moz-document with an empty URL, it detects Gecko<br>
&lt;TabAtkins> dbaron: the original motivation was for user stylesheets<br>
&lt;astearns> q-<br>
&lt;TabAtkins> lea: URLPattern in JS has the nice feature where you can extract features form the URL. down the line, might be useful to think about designing to match parameters and use them<br>
&lt;TabAtkins> lea: could solve other problems, like SVG Params spec<br>
&lt;TabAtkins> dbaron: we were actually looking at using URL patterns Params for the pseudo-classes. part of the complicated thing is exactly what to do there, there's multiple things to match between, hard to make ergonomic in CSS.<br>
&lt;lea> s/you can extract features form the URL/you can extract params form the URL/<br>
&lt;TabAtkins> dbaron: part of the reason this isn't ready yet is because I want to figure out the param stuff<br>
&lt;TabAtkins> dbaron: also doing patterns now and route maps later is already what we're thinking<br>
&lt;TabAtkins> JakeA: general support<br>
&lt;astearns> +1 to separating urlpattern()<br>
&lt;TabAtkins> JakeA: perf, relative to a navigation probably not a huge issue to run a little JS<br>
&lt;TabAtkins> JakeA: but wrt back/forward navs, if the Vt has any directionality you want to change if it's a back navigation<br>
&lt;TabAtkins> JakeA: so yes, important to have that doable at a high level<br>
&lt;astearns> ack JakeA<br>
&lt;Zakim> JakeA, you wanted to react to JakeA<br>
&lt;astearns> ack fantasai<br>
&lt;Zakim> fantasai, you wanted to ask about integration with navigation<br>
&lt;TabAtkins> fantasai: I think the draft could use some examples, took a while to figure out what was happening<br>
&lt;TabAtkins> fantasai: I think overall this looks like a reasonable design for the idea<br>
&lt;emilio> q+<br>
&lt;TabAtkins> fantasai: one thing that through me off was the at-rule being @route, it doesn't declare a route it declares a condition based on the current navigation state of the doc<br>
&lt;TabAtkins> fantasai: so my suggestion is to use @navigation instead, and use @route in the future as the named routing feature<br>
&lt;lea> q?<br>
&lt;TabAtkins> fantasai: that would also let you have :route() pseudo matching up<br>
&lt;TabAtkins> fantasai: once I figured out that term confusion it made a lot more sense<br>
&lt;TabAtkins> JakeA: how would that be different from @document if it supported URLPattern?<br>
&lt;emilio> q-<br>
&lt;TabAtkins> fantasai: @document is the current doc, right? but this condition might be the current doc or the active nav<br>
&lt;TabAtkins> JakeA: I meant about @route<br>
&lt;lea> this is a bit like masonry: route is the term of art, but to those not yet inducted into all this it seems very confusing. I still remember how confused I was when I first heard about routes.<br>
&lt;TabAtkins> fantasai: that's for declaring a named route<br>
&lt;TabAtkins> fantasai: can later do @navigation route(foo) {...}<br>
&lt;astearns> route also sounds like root (depending on the speaker)<br>
&lt;TabAtkins> fantasai: [goes over her :route example again]<br>
&lt;lea> `@navigation` sounds like it's about going somewhere, rather than about where you _are_<br>
&lt;lea> q+<br>
&lt;fantasai> It's about the current state of navigation<br>
&lt;fantasai> So yeah, it *is* about going somewhere<br>
&lt;TabAtkins> wendyreid: this also means we can do reduced-motion response, people can turn them off easily if they're in CSS<br>
&lt;TabAtkins> fantasai: that would turn off on the VT side, you can already do that<br>
&lt;astearns> ack wendyreid<br>
&lt;adamargyle> can the common case of back navigation being a reverse of the prior view transition, be a single easy opt in instead of needing to intercept or @route declare the intent which plays keyframes in reverse? seems like something like this could work:<br>
&lt;adamargyle> @view-transition {<br>
&lt;adamargyle>   navigation: auto;<br>
&lt;adamargyle>   backwards: reverse;<br>
&lt;adamargyle> }<br>
&lt;astearns> ack noamr<br>
&lt;astearns> ack lea<br>
&lt;TabAtkins> noamr: I think we had this discussion internally about naming. "route" was a bit of a relic, coming from the HTML history. so this reflects our internal convo<br>
&lt;TabAtkins> lea: echoing from IRC, agree with changing "route". "route" is a term of art, but people not already familiar with it find it weird/confusing<br>
&lt;TabAtkins> lea: I was very confused when I first started learning about this<br>
&lt;TabAtkins> lea: but I also find navigation a bit confusing, sounds like it's about going somewhere or coming from somewhere<br>
&lt;JakeA> q+<br>
&lt;TabAtkins> lea: rather than where you currently are<br>
&lt;Jxck> route mapping json seems quite similar w/ speculation rules.<br>
&lt;Jxck> https://developer.mozilla.org/en-US/docs/Web/API/Speculation_Rules_API<br>
&lt;noamr> q+<br>
&lt;TabAtkins> lea: Elika said it *is* about coming from somewhere, but I thought this was most about where you are<br>
&lt;TabAtkins> dbaron: the current proposal has both<br>
&lt;astearns> ack Jxck<br>
&lt;TabAtkins> dbaron: the thing we're probably focused on more is the "where are you going", not "where you are", but it can do both<br>
&lt;astearns> ack JakeA<br>
&lt;TabAtkins> JakeA: these rules apply during same-doc navigations too, right/<br>
&lt;TabAtkins> noamr: yes<br>
&lt;TabAtkins> lea: and the rule can be used for other things than VT<br>
&lt;astearns> ack noamr<br>
&lt;TabAtkins> noamr: scoping back to what do we need to do to get this into an ED<br>
&lt;TabAtkins> noamr: we're not trying to figure out these issues today<br>
&lt;astearns> ack fantasai<br>
&lt;TabAtkins> JakeA: examples<br>
&lt;TabAtkins> fantasai: yes<br>
&lt;TabAtkins> fantasai: add examples, put in ED<br>
&lt;kbabbitt> +1 fantasai<br>
&lt;fantasai> @navigation (at: urlpattern) {<br>
&lt;fantasai>     styles that apply to a page at urlpattern<br>
&lt;fantasai> }<br>
&lt;fantasai> @navigation (from: urlpattern1) and (to: urlpattern2) {<br>
&lt;fantasai>  styles that apply when you are navigating from urlpattern1 to urlpattern2<br>
&lt;fantasai> }<br>
&lt;fantasai> @navigation (route: --foo) {<br>
&lt;fantasai>  styles that apply when navigation state is --foo<br>
&lt;fantasai> }<br>
&lt;JakeA> q+<br>
&lt;fantasai> @route --foo {<br>
&lt;fantasai>  from: urlpattern3;<br>
&lt;fantasai>  to: urlpattern4;<br>
&lt;fantasai> }<br>
&lt;fantasai> a:route(--foo) {<br>
&lt;fantasai>  styles for link that go from urlpattern3 to urlpattern4<br>
&lt;fantasai> }<br>
&lt;fantasai> a:route-to(urlpattern) {<br>
&lt;fantasai>  styles for link that go to urlpattern<br>
&lt;fantasai> }<br>
&lt;TabAtkins> JakeA: what's the lifetime of the @navigation rule? especially with a from()<br>
&lt;astearns> ack JakeA<br>
&lt;TabAtkins> noamr: directly tied to Navigation API concepts<br>
&lt;TabAtkins> noamr: navigation.transition have "from" and "to", it's tied to that<br>
&lt;TabAtkins> JakeA: that doesn't work for cross-document<br>
&lt;TabAtkins> noamr: I have a proposal to fix that<br>
&lt;TabAtkins> noamr: the "from" and "to" starts at the navigate event, "to" changes at redirect and swap<br>
&lt;TabAtkins> noamr: and in the next document, the "to" is only until the first frame<br>
&lt;TabAtkins> JakeA: makes sense<br>
&lt;TabAtkins> noamr: first frame + view transition<br>
&lt;TabAtkins> astearns: so details like that in the draft, examples<br>
&lt;TabAtkins> noamr: so suggesting css-navigation for the ED name<br>
&lt;TabAtkins> astearns: any objections to doing an ED yet?<br>
&lt;JakeA> q+<br>
&lt;TabAtkins> astearns: proposed to start an ED for css-navigation<br>
&lt;TabAtkins> JakeA: I think most important part of this is back vs forward, that's not part of this yet, right?<br>
&lt;TabAtkins> noamr: not at the moment<br>
&lt;TabAtkins> JakeA: okay I think it should be<br>
&lt;TabAtkins> JakeA: [summarizes what he meant again]<br>
&lt;TabAtkins> RESOLVED: Start a css-navigation ED<br>
&lt;JakeA> dbaron: https://simple-vt-demos.jakearchibald.com/directional-transition/ - this transition moves differently if you use the back button. I think this is a really common case<br>
</details>


-- 
GitHub Notification of comment by css-meeting-bot
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/12594#issuecomment-3530564088 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Friday, 14 November 2025 02:34:39 UTC