Phi
Link
@dicehub/phiv1.0.0-beta.1

Link

A styled anchor component for inline text links with multiple variants and external-link indicators.

<script setup>
import { Link } from "@dicehub/phi/components/link";
</script>

<template>
  <div class="flex flex-wrap items-center gap-4">
    <Link href="#">Default inline link</Link>
    <Link href="#" variant="current">Current color link</Link>
    <Link href="#" variant="plain">Plain inline link</Link>
  </div>
</template>

Installation

Barrel

import { Link } from "@dicehub/phi";

Granular

import { Link } from "@dicehub/phi/components/link";

Usage

The default Link renders an underlined anchor with primary link color styling.

<script setup>
import { Link } from "@dicehub/phi/components/link";
</script>

<template>
  <p>
    Read our <Link href="/docs">documentation</Link> for more details.
  </p>
</template>

Use Link.ExternalIcon to indicate links that open in a new tab.

<script setup>
import { Link } from "@dicehub/phi/components/link";
</script>

<template>
  <Link
    href="https://example.com"
    target="_blank"
    rel="noopener noreferrer"
  >
    Visit example <Link.ExternalIcon />
  </Link>
</template>

Framework Integration

Routing behavior belongs to the application. Compose Link with your router's custom link slot when client-side navigation is required.

<script setup>
import { Link } from "@dicehub/phi/components/link";
</script>

<template>
  <RouterLink to="/dashboard" custom v-slot="{ href, navigate }">
    <Link :href="href" @click="navigate">Dashboard</Link>
  </RouterLink>
</template>
<script setup>
import { Link } from "@dicehub/phi/components/link";
</script>

<template>
  <RouterLink to="/dashboard" custom v-slot="{ href, navigate }">
    <Link :href="href" variant="inline" @click="navigate">
      Dashboard
    </Link>
  </RouterLink>
</template>

Examples

Inline in Paragraph

Links keep their underline offset readable inside body text.

<script setup>
import { Link } from "@dicehub/phi/components/link";
</script>

<template>
  <p>
    This is a paragraph with an <Link href="#">inline link</Link> that flows
    naturally with the surrounding text. Links maintain proper underline
    offset for readability.
  </p>
</template>

Use Link.ExternalIcon to mark links that open in a new tab.

<script setup>
import { Link } from "@dicehub/phi/components/link";
</script>

<template>
  <Link
    href="https://example.com"
    target="_blank"
    rel="noopener noreferrer"
  >
    Visit example <Link.ExternalIcon />
  </Link>
</template>

Current Variant (Color Inheritance)

Use current when the link should inherit color from its parent.

<script setup>
import { Link } from "@dicehub/phi/components/link";
</script>

<template>
  <p class="message">
    This error message contains a
    <Link href="#" variant="current">link</Link>
    that inherits the parent color.
  </p>
</template>

Use plain for navigation-style links where underlines are distracting.

<script setup>
import { Link } from "@dicehub/phi/components/link";
</script>

<template>
  <nav aria-label="Footer">
    <Link href="#" variant="plain">Status</Link>
    <Link href="#" variant="plain">Support</Link>
    <Link href="#" variant="plain">Security</Link>
  </nav>
</template>

Use your router's custom slot when Link should keep Phi styling during client-side navigation.

<script setup>
import { Link } from "@dicehub/phi/components/link";
</script>

<template>
  <RouterLink to="/dashboard" custom v-slot="{ href, navigate }">
    <Link :href="href" variant="inline" @click="navigate">
      Dashboard
    </Link>
  </RouterLink>
</template>

Test IDs

Link forwards standard anchor attributes for testing and accessibility.

<script setup>
import { Link } from "@dicehub/phi/components/link";
</script>

<template>
  <Link href="/docs" data-testid="docs-link" aria-label="Open docs">
    Docs
  </Link>
</template>

API Reference

Extends native anchor element attributes.

PropTypeDefaultDescription
variant"inline" | "current" | "plain""inline"Visual style of the link.
hrefstring-Link destination URL.
targetstring-Native anchor target attribute.
relstring-Native anchor rel attribute.
default slotslot-Link content.
classstring-Additional CSS classes.

Variants

VariantDescriptionUse Case
inlinePrimary link color with underline.Inline text links.
currentInherits color from parent text with underline.Alerts or colored text.
plainPrimary link color without underline.Navigation, menus, footers.

SVG icon component to indicate external links. It accepts standard SVG attributes and is hidden from assistive technology.

Design Guidelines

When to Use Each Variant

Use inline for body copy, current inside colored text, and plain for compact navigation groups.

Pair target="_blank" links with rel="noopener noreferrer" and Link.ExternalIcon when the destination leaves the current app.

Framework Integration

Keep routing behavior in the application layer and pass the resolved href into Link.

Accessibility

Use descriptive link text and avoid relying on the icon alone to explain the destination.