Link

Link

A navigational element for routing between pages or external resources with support for icons, external indicators, and various visual styles.


Import

tsx
import { Link } from "asheeui";

Usage

tsx
import { Link } from "asheeui";
export default function Basic() {
return <Link href="/about">About Us</Link>;
}

Examples

Color

Variant

Size

Underline behavior

With icons

Disabled

Combined example


Props

PropTypeDefaultDescription
hrefstringNoneTarget URL
variant"default" | "muted" | "subtle""default"*Visual style of the link
color"none" | "default" | "primary" | "secondary" | "danger" | "warning" | "success""primary"*Semantic color
size"sm" | "md" | "lg""md"Size scale
underline"always" | "hover" | "never""hover"*Underline behavior
isExternalbooleanfalse*Shows external link icon and sets target/rel
disabledbooleanfalseDisables interaction
startIconReactNodeNoneIcon displayed before text
endIconReactNodeNoneIcon displayed after text
childrenReactNodeNoneLink content
targetstringNoneLink target attribute
relstringNoneLink rel attribute
linkComponentReact.ElementTypeNoneCustom link component (e.g., Next.js Link, TanStack Router Link). Replaces the native <a> tag.
linkPropsRecord<string, unknown>NoneAdditional props passed to the custom link component (e.g., { prefetch: true }). Merged with and takes precedence over native anchor props.
classNamestringNoneExtra classes, merged with internal styles

* Falls back through Global Configuration if not set. See below.


Global Configuration

Link reads defaults from four places, in this order of precedence:

  1. Instance prop: set directly on <Link />
  2. Component config: components.link in your ashee.config
  3. Theme default: defaultColor in your ashee.config
  4. Built-in fallback: component's internal default values

Component config

ts
// ashee.config.ts
import type { ExternalConfig } from "asheeui";
export const config: ExternalConfig = {
components: {
link: {
variant: "default",
color: "primary",
size: "md",
underline: "hover",
isExternal: false,
},
},
};

Built-in fallbacks

ts
{
size: "md",
variant: "default",
color: "primary",
underline: "hover",
isExternal: false,
}

Accessibility

  • Renders a native <a> element (or custom link component) with proper semantics
  • External links automatically include rel="noopener noreferrer" for security
  • Uses aria-disabled for disabled state
  • Disabled links remove href attribute to prevent navigation
  • Implements focus-visible rings for keyboard navigation

Notes

  • External Links: When isExternal is true, the link automatically opens in a new tab with proper security attributes (target="_blank" and rel="noopener noreferrer").
  • External Indicator: An external link icon is automatically added when isExternal is true (unless overridden by endIcon).
  • Disabled State: Disabled links have reduced opacity, no hover effects, and cannot be clicked.
  • Underline Behavior: underline="hover" shows underline only on hover, underline="always" always shows underline, and underline="never" never shows underline.
  • Variant Muted: The muted variant uses a muted foreground color that brightens on hover, useful for less prominent links.
  • Variant Subtle: The subtle variant uses reduced opacity that increases on hover.
  • Custom Link Component: You can replace the default <a> tag with any routing‑library link component (e.g., Next.js Link, TanStack Router Link) using the linkComponent prop. Additional props can be passed via linkProps. All styles, interactions, and accessibility features are preserved.
Previous

← Keyboard

Next

Marquee →