Text Link

Text link for inline internal and external links with router integration, color inheritance, underline control, and weight options.

import { TextLink } from "@plexui/vue/components/TextLink";

Examples

Overview

Inline usage

Default inheritance

colorClassName

Primary color

Underline

Font weight

API

PropTypeDefaultDescription
default slotVNode[]—Link content
hrefstring—URL. An http:// or https:// URL is external
tostring | Record<string, unknown>—Router link destination (internal), such as a vue-router location
primarybooleanfalsePrimary color, no default underline
underlinebooleantrueUnderline (default true unless primary)
force-externalboolean—Force external link behavior
asComponent—Link component (e.g. RouterLink, NuxtLink)
targetstring—Where to open the link. External links default to _blank
classstring—Extra classes on the link

External links render an <a> with target="_blank" (unless you pass target) and rel="noopener noreferrer". Without href or to, TextLink renders a <span role="button">; with a @click listener it takes Tab and runs on Enter or Space. Other attributes and listeners are forwarded.

Configure your Router

Wrap your app in PlexUIProvider and pass your router's link component. You can also pass the link component to the as prop on TextLink for a component-level override. A link component that declares a to prop, such as vue-router's RouterLink or NuxtLink, receives href as to when no to is given, so <TextLink href="/help"> works with either.

<script setup lang="ts">
import { RouterLink, RouterView } from "vue-router"
import { PlexUIProvider } from "@plexui/vue/components/PlexUIProvider"
</script>

<template>
  <PlexUIProvider :link-component="RouterLink">
    <RouterView />
  </PlexUIProvider>
</template>
<TextLink to="/help">Get Help</TextLink>

<TextLink :as="NuxtLink" to="/dashboard">View Dashboard</TextLink>

Styling

Text Link reads these component tokens. Override them at any scope to restyle it:

  • --link-font-weight: font weight (default inherit)
  • --link-gap: gap (default spacing(0.5))
  • --link-primary-text-color: primary text color (default light-dark(var(--blue-500), var(--blue-300)))
  • --link-primary-text-color-hover: primary text color hover (default light-dark(var(--blue-600), var(--blue-400)))
  • --link-radius: radius (default var(--radius-sm))
  • --link-underline-decoration-offset: underline decoration offset (default 0.1em)