Link
Usage
The Link component is a wrapper around <NuxtLink> using the custom prop. It provides a few extra props:
- inactive-classprop to set a class when the link is inactive,- active-classis used when active.
- exactprop to style with- active-classwhen the link is active and the route is exactly the same as the current route.
- exact-queryand- exact-hashprops to style with- active-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.
Tag
The Link components renders an <a> tag when a to prop is provided, otherwise it renders a <button> tag. You can use the as prop to change fallback tag.
<template>
  <ULink as="button">Link</ULink>
</template>
to prop.Style
By default, the link has default active and inactive styles, check out the #theme section.
<template>
  <ULink to="/components/link">Link</ULink>
</template>
to prop to see the active and inactive states.You can override this behavior by using the raw prop and provide your own styles using class, active-class and inactive-class.
<template>
  <ULink raw to="/components/link" active-class="font-bold" inactive-class="text-muted">Link</ULink>
</template>
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:
{
  "tailwindCSS.classAttributes": [
    "active-class",
    "inactive-class"
  ]
}
API
Props
| Prop | Default | Type | 
|---|---|---|
| as | 
 The element or component this component should render as when not a link. | |
| type | 
 | 
 The type of the button when not a link. | 
| disabled | 
 | |
| active | 
 | 
 Force the link to be active independent of the current route. | 
| exact | 
 Will only be active if the current route is an exact match. | |
| exactQuery | 
 Allows controlling how the current route query sets the link as active. | |
| exactHash | 
 Will only be active if the current route hash is an exact match. | |
| inactiveClass | 
 The class to apply when the link is inactive. | |
| raw | 
 When  | |
| to | Route Location the link should navigate to when clicked on. 
 | |
| href | 
 An alias for  
 | |
| external | 
 Forces the link to be considered as external (true) or internal (false). This is helpful to handle edge-cases | |
| target | 
 Where to display the linked URL, as the name for a browsing context. | |
| rel | 
 A rel attribute value to apply on the link. Defaults to "noopener noreferrer" for external links. | |
| noRel | 
 If set to true, no rel attribute will be added to the link | |
| prefetchedClass | 
 A class to apply to links that have been prefetched. | |
| prefetch | 
 When enabled will prefetch middleware, layouts and payloads of links in the viewport. | |
| prefetchOn | 
 Allows controlling when to prefetch links. By default, prefetch is triggered only on visibility. | |
| noPrefetch | 
 Escape hatch to disable  | |
| activeClass | 
 Class to apply when the link is active | |
| exactActiveClass | 
 Class to apply when the link is exact active | |
| ariaCurrentValue | 
 | 
 Value passed to the attribute  | 
| viewTransition | 
 Pass the returned promise of  | |
| replace | 
 Calls  | 
Slots
| Slot | Type | 
|---|---|
| default | 
 | 
Theme
export default defineAppConfig({
  ui: {
    link: {
      base: 'focus-visible:outline-primary',
      variants: {
        active: {
          true: 'text-primary',
          false: 'text-muted'
        },
        disabled: {
          true: 'cursor-not-allowed opacity-75'
        }
      },
      compoundVariants: [
        {
          active: false,
          disabled: false,
          class: [
            'hover:text-default',
            'transition-colors'
          ]
        }
      ]
    }
  }
})
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'
export default defineConfig({
  plugins: [
    vue(),
    ui({
      ui: {
        link: {
          base: 'focus-visible:outline-primary',
          variants: {
            active: {
              true: 'text-primary',
              false: 'text-muted'
            },
            disabled: {
              true: 'cursor-not-allowed opacity-75'
            }
          },
          compoundVariants: [
            {
              active: false,
              disabled: false,
              class: [
                'hover:text-default',
                'transition-colors'
              ]
            }
          ]
        }
      }
    })
  ]
})
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import uiPro from '@nuxt/ui-pro/vite'
export default defineConfig({
  plugins: [
    vue(),
    uiPro({
      ui: {
        link: {
          base: 'focus-visible:outline-primary',
          variants: {
            active: {
              true: 'text-primary',
              false: 'text-muted'
            },
            disabled: {
              true: 'cursor-not-allowed opacity-75'
            }
          },
          compoundVariants: [
            {
              active: false,
              disabled: false,
              class: [
                'hover:text-default',
                'transition-colors'
              ]
            }
          ]
        }
      }
    })
  ]
})