You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/routes/solid-router/reference/components/a.mdx
+27-3Lines changed: 27 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -2,11 +2,35 @@
2
2
title: A
3
3
---
4
4
5
-
Like the [`<a>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a) tag but supports relative paths and active class styling (requires client side JavaScript).
5
+
Solid-Router exposes an `<A />` component as a wrapper around the native [`<a />`](https://mdn.io/a) tag.
6
+
7
+
`<A />` supports relative and base paths. `<a />` doesn't. But `<a />` gets augmented
8
+
when JS is present via a top-level listener to the DOM, so you get the
9
+
soft-navigation experience nonetheless.
10
+
11
+
The `<A />` supports the [`<Router />`](/solid-router/reference/components/router) base property (`<Router base="/subpath">`) and prepend it to the received `href` automatically and the `<a />`does not.
12
+
The same happens with relative paths passed to `<A />`.
6
13
7
14
The `<A>` tag has an `active` class if its href matches the current location, and `inactive` otherwise.
8
-
**Note:** By default matching includes locations that are descendents (eg. href `/users` matches locations `/users` and `/users/123`), use the boolean `end` prop to prevent matching these.
9
-
This is particularly useful for links to the root route `/` which would match everything.
15
+
By default matching includes locations that are descendants (e.g.: href `/users` matches locations `/users` and `/users/123`).
16
+
17
+
<Callouttype="tip">
18
+
Use the boolean `end` prop to prevent matching these. This is particularly
19
+
useful for links to the root route `/` which would match everything.
20
+
</Callout>
21
+
22
+
## Soft Navigation
23
+
24
+
When JavaScript is present at the runtime, both components behave in a very similar fashion.
25
+
This is because Solid-Router adds a listener at the top level of the DOM and will augment the native `<a />` tag to a more performant experience (with soft navigation).
26
+
27
+
<Callouttype="info">
28
+
29
+
To prevent, both `<A />` and `<a />` tags from soft navigating when JavaScript is present, pass a `target="_self"` attribute.
0 commit comments