Getting Started

  • Introduction
  • Installation

Components

  • Button
  • Switch
  • Avatar
  • Callout
  • Avatar Group
  • Card
  • Divider
  • Link
  • Page
  • PageBody
  • Page Marquee
  • PageSection
  • Toasts

Typography

  • Introduction
  • Fields
  • Code Preview
Mockline v0.17.3

Link

A versatile link component that supports both internal and external navigation with active state detection and various styling options.

Overview

The Link component is a fundamental navigation element that enhances the standard HTML anchor with features like active state detection, external link handling, and various styling options. It's built on top of Nuxt's routing system while maintaining accessibility and user experience.

Features

  • Multiple variants (solid, soft, subtle, ghost, link)
  • Active state detection for current routes
  • Support for external and internal links
  • Exact matching options for routes
  • Disabled state support
  • Accessible by default
  • Customizable styling

Usage

Basic Link

The simplest way to use the link is with text content:

Home

External Links

Links automatically handle external URLs with appropriate attributes:

Nuxt Website

Active State

Links can show an active state when matching the current route:

Active Link

Regular Link

Exact Matching

Control how the active state is determined:

Exact Match

Partial Match

Disabled State

Links can be disabled to prevent navigation:

Disabled Link

Props

to
string

The target route path for internal navigation.

href
string

The URL for external links.

active
boolean

Manually set the active state of the link.

exact
boolean

When true, the active state requires an exact route match.

disabled
boolean

Disables the link, preventing navigation.

target
'_blank' | '_self' | '_parent' | '_top'

Specifies where to open the linked document.

rel
string

Specifies the relationship between the current document and the linked document.

isExternal
boolean

Forces the link to be treated as an external link.

Slots

default
any

The default slot for link content.

Best Practices

  1. Use appropriate props for different scenarios:
    • Use to for internal navigation within your application
    • Use href for external links
    • Add target="_blank" for links that open in new tabs
  2. Implement proper active states:
    • Use exact when you need precise route matching
    • Consider the hierarchy of your routes when setting up active states
  3. Maintain accessibility:
    • Provide clear and descriptive link text
    • Use appropriate ARIA attributes when needed
    • Ensure sufficient color contrast for active and inactive states
  4. Security considerations:
    • Add appropriate rel attributes for external links
    • Use rel="noopener noreferrer" when opening links in new tabs
  5. Handle edge cases:
    • Implement proper disabled states when needed
    • Consider loading states for async navigation
    • Handle external links appropriately with the isExternal prop
Divider
A flexible divider component that can be used to separate content with optional labels, icons, and various styles.
Page
A flexible container component for building structured page layouts with optional sidebars.