PeakUI

Link

A styled navigation link with optional icon

Usage

import {Link} from "@peakui/react";

Anatomy

import {Link} from "@peakui/react";

export default () => (
  <Link href="/pricing">
    Pricing
    <Link.Icon />
  </Link>
);

Examples

Custom Icon

Link.Icon renders the built-in external-link glyph unless you pass your own children.

Icon Placement

The icon slot renders wherever you place it relative to the label.

Underline

The base ships underline-offset-4 with no underline; utilities on className decide when it shows.

Disabled State

isDisabled sets aria-disabled="true" and keeps the link in the accessibility tree.

Button Variants

Combining with the button classes turns the link into a tertiary button-shaped anchor.

Customization

Tailwind CSS

<Link className="underline underline-offset-2" href="/pricing">
  Pricing
</Link>

Global CSS

@layer components {
  .link {
    --color-link: var(--color-accent);
  }
}

Styling Reference

PeakUI follows the BEM methodology, so variants and states are plain class names you can target.

CSS Classes

The Link component uses these CSS classes (view source styles):

Base Classes

  • .link - Base link styles: inline-flex, text-link color, hover underline with offset

Element Classes

  • .link__icon - The icon slot: 0.75em box, decorative, opacity-60 until hover
  • .link__icon[data-default-icon="true"] - Spacing applied when the built-in glyph is used

Modifier Classes

  • .button - Composition hook: .link.button drops the gap and the underline

Slots

  • [data-slot="link"] - The root anchor element
  • [data-slot="link-icon"] - The icon slot element
  • [data-slot="link-default-icon"] - The built-in external-link <svg>

Interactive States

The component supports both CSS pseudo-classes and data attributes:

  • Hover: :hover or [data-hovered]
  • Pressed: :active or [data-pressed]
  • Focus: :focus-visible or [data-focus-visible]
  • Disabled: [aria-disabled="true"]

API Reference

PropTypeDefaultDescription
childrenReactNode | ((values: LinkRenderProps) => ReactNode)-The link content, or a function of the render props
hrefstring-The URL the link navigates to
isDisabledboolean-Sets aria-disabled="true" and blocks navigation
classNamestring | ((values: LinkRenderProps) => string)-Additional classes, or a function of the render props
renderPossibleLinkDOMRenderProps<'span', LinkRenderProps>-Replaces the rendered <a> with your own element

Every other attribute of an <a> is accepted.

Link.Icon

PropTypeDefaultDescription
childrenReactNode-Replaces the built-in external-link glyph
classNamestring-Additional classes
renderDOMRenderFunction<'span', undefined>-Replaces the rendered <span> with your own element

Every other attribute of a <span> is accepted.

Render Props

PropTypeDescription
children(values: LinkRenderProps) => ReactNodeReceives isCurrent, isDisabled, isHovered, isPressed, isFocused, isFocusVisible
className(values: LinkRenderProps) => stringSame values as children

On this page