General · astro-ui · Link

Link

Semantic anchor with external/rel smarts, icons, colors, and a disabled state.

Link renders a styled <a> with smart defaults: external or target=“_blank” links automatically get rel=“noopener noreferrer” (opt out with noRel or a custom rel). Disabled links drop their href and mute out. Icons are currentColor CSS masks — no JS, no icon dependency. Navigation hints like prefetch, replace, and viewTransition only render data-* attributes for your router or islands to adopt.

Features

  • Auto rel="noopener noreferrer" for external/_blank
  • 7 colors, 3 sizes, optional underline
  • arrow / chevron / external / download icons
  • Disabled & loading states
  • data-* navigation hooks — zero JS

Usage

---
import { Link } from "astro-ui";
---

<Link href="https://astro.build" external icon="external">Astro</Link>

Demos

API

Props

PropTypeDefaultDescription
hrefstring—Link URL. Omitted for non-interactive links.
externalbooleanfalseMarks the link external; defaults rel to "noopener noreferrer".
targetstring—Browsing-context target (e.g. "_blank"). Implies the external rel default.
rel / noRelstring / boolean—Custom rel, or omit rel entirely.
icon"arrow" | "chevron" | "external" | "download"—CurrentColor icon before the text.
iconOnlybooleanfalseIcon-only mode (provide ariaLabel).
size"sm" | "md" | "lg""md"Text scale.
underlinebooleantrueText underline.
color"primary" | "secondary" | "muted" | "destructive" | "success" | "warning" | "inherit""primary"Text color.
blockbooleanfalseFill the parent's inline width.
disabledbooleanfalseNon-interactive: drops href and mutes.
loadingbooleanfalsePending state; swaps content for loadingText.
loadingTextstring—Content while loading (falls back to the slot).
ariaCurrent"page" | "step" | "location" | "date" | "true" | "false"—aria-current marker.
download / hreflang / ping / referrerPolicy——Forwarded verbatim to the anchor.
prefetch / prefetchOn / noPrefetchboolean / string / boolean—Render data-* hints for your router; no JS shipped.
replace / viewTransitionbooleanfalseMore data-* navigation hints (replaceState, View Transitions).
classstring—Merged via cn(); Tailwind classes welcome.
idstring—Element id.
ariaLabelstring—Accessible name.

Slots

SlotDescription
defaultLink text or custom content.

Accessibility

Implemented accessibility features — semantics, ARIA wiring, and keyboard behavior that ship with the component.

  • Native anchor semantics; external links announce their target via aria-label
  • aria-current for the active page; aria-disabled for disabled links
  • :focus-visible ring

FAQ

Do prefetch, replace, or viewTransition do anything by themselves?

No — deliberately. They render data-* attributes so a router, an Astro island, or a small script can adopt them. The component itself ships zero JavaScript.

Changelog

Version history mentioning Link.

v0.1.0 — 2026-11-11
added
  • General (7): Button, ButtonGroup, Command, Carousel, Clipboard, Kbd, Link.