C&C Docs
Log in

cnc-link

A link that navigates WITHOUT a page load, pushing the new URL into browser history. It also carries "targets" — extra destinations encoded into the query string for a page with several independent regions.

Quick start

Give it an href and slot the link text. Note the default: with no targets and no navigate="true" it behaves as an ORDINARY link and lets the browser load the page.

<cnc-link href="/widgets">An ordinary link</cnc-link>
<cnc-link href="/widgets" navigate="true">A history push</cnc-link>

Usage guidance

navigate is a STRING compared against "true". A bare navigate attribute or :navigate="true" as a boolean will not enable it — spell it navigate="true", or set targets and let it switch itself.

Pushing history is only half of navigating. The widget changes the URL; something else has to notice and render it. Where nothing is listening, the address bar moves and the page does not, which looks broken.

For an ordinary link, an ordinary <a> is fine and lighter. Reach for this when you want the history push or the multi-region targets — those are the two things it adds.

prevent is truthiness, with one exception: the literal string "false" reads as false, so a stringly-typed attribute does not lock a link by accident. A bare prevent attribute is the empty string and does NOT prevent — bind it (:prevent="expr") or write prevent="true".

A prevented link is not an access control. It stops the click; it does not stop somebody typing the address. Whatever the link guards has to check for itself on the way in.

← Back to Widgets