• About Us
  • Privacy Policy
  • Disclaimer
  • Contact Us
AimactGrow
  • Home
  • Technology
  • AI
  • SEO
  • Coding
  • Gaming
  • Cybersecurity
  • Digital marketing
No Result
View All Result
  • Home
  • Technology
  • AI
  • SEO
  • Coding
  • Gaming
  • Cybersecurity
  • Digital marketing
No Result
View All Result
AimactGrow
No Result
View All Result

CSS Navigation Matching, Early Days

Admin by Admin
August 19, 2026
Home Coding
Share on FacebookShare on Twitter


Actually just like the intent right here. Apply a mode when somebody navigates from one particular web page to a different. The concept being it’d make the sources for cross-document view transitions declarative in CSS relatively than managing that stuff in JavaScript.

Bramus has a hypothetical instance as this function is fleshed out:

  • Outline the @location, i.e., the URLs concerned within the transition. Bramus makes use of @route however that seems to have modified since their publish.
  • Question the @navigation between routes.
  • Choose the factor that’s transitioned on every route.

So:

/* Outline the areas */
@location --contact-page {
  pathname: ("/contact");
}

@location --contact-confirmation {
  pathname: ("/contact/thanks");
}

That’s for after we know the actual pages we’re navigating from and to. There’s URL sample matching as nicely for the instances we don’t:

@location --article {
  sample: url-pattern("/article/:id");
}

/* 
  The place :id matches something two ranges deep like:
  /article/25
  /article/3785
  /article/no matter
*/

There are extra methods to outline the @location apart from the pathname and url-pattern descriptors. Like perhaps you’re attempting to match a hash-ed URL as an alternative, or a selected port or hostname. Apparently there’s protocol and search too, however truthfully, I’d should see examples and use circumstances to grasp when to make use of one descriptor over one other.

OK, so then now we have a solution to question the @navigation between areas utilizing the customized idents registered within the @location. If the navigation matches the 2 factors of navigation, then bingo.

/* Fireplace a transition when navigating between these two pages */
@navigation (from: --contact) and (to: --contact-confirmation) {
  /* Apply transition */
}

Fairly clear from and to situations there the place they’re related by an and key phrase.

One other solution to write it that’s a tad cleaner:

/* Fireplace a transition when navigating between these two pages */
@navigation (between: --contact and --contact-confirmation) {
  /* Apply transition */
}

Or, hey, we are able to fireplace this off when there’s not a match:

/* Fireplace a transition, however NOT when navigating between these two pages */
@navigation not (between: --contact and --contact-confirmation) {
  /* Apply transition */
}

There’s additionally an at key phrase to attach areas. The spec draft is obscure on this in the mean time, however Bramus demonstrates it like this:

@navigation (between: --home and --detail) {
  @navigation (at: --home) {
    /* Goal the clicked hyperlink's picture */
    :nav-source img {
      view-transition-name: picture;
    }
  }
}

I’ve gotta wrap my head round that. The way in which I learn it, it says, “once you’re navigating between --home and --detail and also you’re beginning ‘at’ --home, choose this factor and provides it this view transition identify.” In different phrases, it occurs on the very, very starting (or finish, I suppose) of the navigation between pages relatively than when it’s in progress. I feel. Please appropriate me.

And what about that :nav-source pseudo (which can be renamed to :navigation-source)? Once more, gotta wrap my head round all of it. However if I’m understanding proper, that’s to match the particular factor that triggers the transition. It’s the supply of the navigation, be it a hyperlink, picture, div, or no matter factor. I didn’t see something within the spec draft a few corresponding pseudo that matches the factor on the opposite facet of the transition — say, :goal? — however maybe there’s no clear use case for it.

Talking of pseudos, the spec defines one other one known as :link-to() that applies kinds to a linked factor that targets a sure location. Straight from the spec:

@location --homepage {
  sample: url-pattern("https://css-tricks.com/");
}

:link-to(--homepage) {
  font-weight: daring;
}

…which I think about matches a component in HTML like:

Again to Residence

…which I feel is so much like styling hyperlinks primarily based on their focused vacation spot? Possibly it’s extra a DX comfort when there’s already a declared location?

Couple notes

One factor I’m already not liking is that I doubt these options would work for a web site like CSS-Tips that has such a flat URL construction. Most of our URLs are a single stage deep. So, if I wish to match between a selected web page (/about) and any article (/article-url) there’s no solution to distinguish that route. However perhaps that claims one thing about the way in which URLs are designed round right here and they need to have extra construction. That’s not a trivial change although.

My pal Lee Meyer means that maybe it might be attainable to append a a parameter like ?weblog on URL to achieve URL sample matching superpowers.

Oh, and whereas I’m pondering of it, I might see a attainable use case the place you’d wish to apply sure kinds when navigating from one particular web page to a different. Like, perhaps you’re navigating between the homepage and an About web page and wish to model parts on the vacation spot web page primarily based on the place you’re coming from. Taking part in off the sooner instance from Bramus:

@navigation (between: --home and --article) {
  @navigation (at: --article) {
    /* Goal the .article-header factor  */
    .article-header {
      background-image: url('/path-to-image.webp');
    }
  }
}

I dunno. Looks as if there may very well be safety points with that?

And Preethi chimed in on the CSS-Tips Slack channel with what I feel is insightful suggestions:

It could’ve been nice if we had an at-rule for all knowledge infrastructures, much like @property for all property-value pairs, with configurations legitimate as per sort. We might’ve used it as an alternative of @color-profile, @position-try, and now @location.

So true when there’s so many new guidelines to study today. Something that lowers the educational curve is actually price contemplating.

There’s much more to this

You’ll wish to peruse the spec draft for your self to get deeper into the nitty-gritty of issues like navigating primarily based on navigation “sort” (e.g., again, ahead, reload) and navigation “phases” (e.g., loading, prepared, dedicated).

It’s so much to soak up. However so are view transitions as a complete.

Tags: CSSDaysEarlyMatchingNavigation
Admin

Admin

Next Post
No Extra PlayStation Discs Means No Extra Disc Butts

No Extra PlayStation Discs Means No Extra Disc Butts

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recommended.

A Fingers-On Coding Tutorial for Microsoft VibeVoice Masking Speaker-Conscious ASR, Actual-Time TTS, and Speech-to-Speech Pipelines

A Fingers-On Coding Tutorial for Microsoft VibeVoice Masking Speaker-Conscious ASR, Actual-Time TTS, and Speech-to-Speech Pipelines

April 13, 2026
Ubisoft to chop 380 jobs and shut down studios in Canada and Serbia, report claims

Ubisoft to chop 380 jobs and shut down studios in Canada and Serbia, report claims

June 11, 2026

Trending.

The Full Information to EcoGPT

The Full Information to EcoGPT

June 6, 2026
Customers, Progress, and International Tendencies

Customers, Progress, and International Tendencies

March 18, 2026
12 Various Search Engines to Strive (As a substitute of Google)

12 Various Search Engines to Strive (As a substitute of Google)

January 30, 2026
Authorized DUI PPC Companies in Atlanta

Authorized DUI PPC Companies in Atlanta

June 14, 2026
Telegram ban in India sparks a rush to VPNs, rival apps

Telegram ban in India sparks a rush to VPNs, rival apps

June 19, 2026

AimactGrow

Welcome to AimactGrow, your ultimate source for all things technology! Our mission is to provide insightful, up-to-date content on the latest advancements in technology, coding, gaming, digital marketing, SEO, cybersecurity, and artificial intelligence (AI).

Categories

  • AI
  • Coding
  • Cybersecurity
  • Digital marketing
  • Gaming
  • SEO
  • Technology

Recent News

Former Ping Id and CyberArk Executives Be a part of AppViewX to Scale Machine and Agent Id Safety

August 19, 2026
No Extra PlayStation Discs Means No Extra Disc Butts

No Extra PlayStation Discs Means No Extra Disc Butts

August 19, 2026
  • About Us
  • Privacy Policy
  • Disclaimer
  • Contact Us

© 2025 https://blog.aimactgrow.com/ - All Rights Reserved

No Result
View All Result
  • Home
  • Technology
  • AI
  • SEO
  • Coding
  • Gaming
  • Cybersecurity
  • Digital marketing

© 2025 https://blog.aimactgrow.com/ - All Rights Reserved