Skip to content

Commit f5016dd

Browse files
authored
Expand info on <A /> reference to include <a /> (#718)
1 parent 7d9203c commit f5016dd

File tree

1 file changed

+27
-3
lines changed
  • src/routes/solid-router/reference/components

1 file changed

+27
-3
lines changed

src/routes/solid-router/reference/components/a.mdx

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,35 @@
22
title: A
33
---
44

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 />`.
613

714
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+
<Callout type="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+
<Callout type="info">
28+
29+
To prevent, both `<A />` and `<a />` tags from soft navigating when JavaScript is present, pass a `target="_self"` attribute.
30+
31+
</Callout>
32+
33+
## Props Reference
1034

1135
| prop | type | description |
1236
| ------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

0 commit comments

Comments
 (0)