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-linkcolor, hover underline with offset
Element Classes
.link__icon- The icon slot:0.75embox, decorative,opacity-60until hover.link__icon[data-default-icon="true"]- Spacing applied when the built-in glyph is used
Modifier Classes
.button- Composition hook:.link.buttondrops 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:
:hoveror[data-hovered] - Pressed:
:activeor[data-pressed] - Focus:
:focus-visibleor[data-focus-visible] - Disabled:
[aria-disabled="true"]
API Reference
Link
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | ((values: LinkRenderProps) => ReactNode) | - | The link content, or a function of the render props |
href | string | - | The URL the link navigates to |
isDisabled | boolean | - | Sets aria-disabled="true" and blocks navigation |
className | string | ((values: LinkRenderProps) => string) | - | Additional classes, or a function of the render props |
render | PossibleLinkDOMRenderProps<'span', LinkRenderProps> | - | Replaces the rendered <a> with your own element |
Every other attribute of an <a> is accepted.
Link.Icon
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | - | Replaces the built-in external-link glyph |
className | string | - | Additional classes |
render | DOMRenderFunction<'span', undefined> | - | Replaces the rendered <span> with your own element |
Every other attribute of a <span> is accepted.
Render Props
| Prop | Type | Description |
|---|---|---|
children | (values: LinkRenderProps) => ReactNode | Receives isCurrent, isDisabled, isHovered, isPressed, isFocused, isFocusVisible |
className | (values: LinkRenderProps) => string | Same values as children |