NUIv3.0.7

Link

A composable, accessible Link component for modern React applications.

tsx
import { Link } from '@nofinite/nui';

Interactive Preview

Loading preview...

Typographic navigation element designed for inline navigation inside paragraphs, lists, and breadcrumbs. For action-oriented links that require button affordance (padding/background), use Button with asChild instead.


Usage

Basic usage

tsx
import { Link } from '@nofinite/nui';

<Link href="/docs">Documentation</Link>;

Variants

tsx
<Link variant="default">Default</Link>
<Link variant="primary">Primary</Link>
<Link variant="muted">Muted</Link>
<Link variant="danger">Danger</Link>

Underline control

tsx
<Link underline="hover">Hover underline</Link>
<Link underline="always">Always underline</Link>
<Link underline="none">No underline</Link>

Automatically applies secure routing attributes.

tsx
<Link href="https://example.com" isExternal>
  External resource
</Link>

Framework routing (polymorphic)

tsx
'use client';
import NextLink from 'next/link';
import { Link } from '@nofinite/nui';

<Link asChild>
  <NextLink href="/card">Go to card</NextLink>
</Link>;

tsx
'use client';
import NextLink from 'next/link';
import { Button } from '@nofinite/nui';

<Button asChild variant="primary">
  <NextLink href="/dashboard">Go to Dashboard</NextLink>
</Button>;


Variants

Color variants

  • default — neutral text color
  • primary — accent navigation link
  • muted — low emphasis navigation
  • danger — destructive navigation

Underline variants

  • none — removes underline
  • hover — underline appears on hover
  • always — persistent underline

Guidelines

  • Use primary for contextual navigation emphasis
  • Use muted for secondary inline links
  • Use danger only for destructive navigation contexts
  • Prefer hover underline for body text readability

States

  • Default
  • Hover
  • Focus visible
  • Active (browser native)
  • Disabled (via native anchor behavior)
  • External link state

Keyboard Interaction

KeyBehavior
TabMoves focus to link
EnterActivates navigation
Shift + TabMoves focus backward

Accessibility

  • Uses semantic <a> element by default
  • Preserves accessibility when asChild is used
  • focus-visible outline ensures keyboard focus visibility
  • External links include security attributes preventing tabnabbing
  • Underline ensures link affordance in text contexts
  • Compatible with screen readers via native anchor semantics


Best Practices

Do

  • Use for inline navigation inside text
  • Use asChild for framework router integration
  • Use isExternal for outbound links
  • Maintain underline in long-form content

Don’t

  • Use for button-like CTAs with backgrounds
  • Remove underline in dense paragraph navigation without other affordance
  • Use danger variant for non-destructive navigation

API Reference

PropTypeDefaultDescription
variantenumdefault
underlineenumhover
isExternalbooleanfalseAutomatically applies `target="_blank"` and `rel="noopener noreferrer"` for external routing security.
asChildbooleanfalse* Polymorphic Prop: When true, delegates rendering to its child. Crucial for integrating with framework routers like Next.js `<Link>` or React Router.