Components
Link
Render a NuxtLink but with superpowers.
Usage
The Link component is a wrapper around <NuxtLink> through the custom prop that provides a few extra props:
inactive-classprop to set a class when the link is inactive,active-classis used when active.exactprop to style withactive-classwhen the link is active and the route is exactly the same as the current route.exact-queryandexact-hashprops to style withactive-classwhen the link is active and the query or hash is exactly the same as the current query or hash.- use
exact-query="partial"to style withactive-classwhen the link is active and the query partially match the current query.
- use
The incentive behind this is to provide the same API as NuxtLink back in Nuxt 2 / Vue 2. You can read more about it in the Vue Router migration from Vue 2 guide.
{
"message": "You should use slots with <ContentRenderer>",
"value": {},
"excerpt": false,
"tag": "div"
}It also renders an <a> tag when a to prop is provided, otherwise it defaults to rendering a <button> tag. The default behavior can be customized using the as prop.
It is used underneath by the Button, Dropdown and VerticalNavigation components.
IntelliSense
If you're using VSCode and wish to get autocompletion for the classes active-class and inactive-class, you can add the following settings to your .vscode/settings.json:
.vscode/settings.json
{
"tailwindCSS.classAttributes": [
"active-class",
"inactive-class"
],
}
Props
type
string
"button"replace
NuxtLinkProps
target
NuxtLinkProps
noRel
NuxtLinkProps
prefetch
NuxtLinkProps
noPrefetch
NuxtLinkProps
activeClass
NuxtLinkProps
exactActiveClass
NuxtLinkProps
prefetchedClass
NuxtLinkProps
ariaCurrentValue
NuxtLinkProps
external
NuxtLinkProps
as
string
"button"exactQuery
boolean | "partial"
falseinactiveClass
string
undefinedto
RouteLocationRaw
href
RouteLocationRaw
rel
any
disabled
boolean
nullactive
boolean
undefinedexact
boolean
falseexactHash
boolean
false