Skip to Content
CodeUI

Link

@codeui/solid v0.3.0

An inline navigation link with an optional hover underline.

When to use

Use Link for navigation in text, such as a reference to a snippet or the source repository.

When to choose another component

Use Button for an action or prominent navigation styled as a button. Use IconButton for a compact icon action with a tooltip.

Live demo

link/basic.tsx
import { Link } from "@codeui/solid";

export default function Demo() {
	return (
		<Link href="https://codeimage.dev">Open CodeImage</Link>
	);
}

Anatomy

Tap a part to outline it in the demo.

  1. 01Linklink
ExportRendersclasses keydata-cuiRole
Linka by defaultNonelinkLink with an href

The root inherits its text color and line height from its parent.

Variants

link/variants.tsx
import { Link } from "@codeui/solid";

export default function Demo() {
	return (
		<div style={{ display: "flex", "flex-wrap": "wrap", gap: "var(--cui-space-3)", "align-items": "center" }}>
			<Link href="https://codeimage.dev">Open CodeImage</Link>
			<Link href="https://codeimage.dev" variant="underline">Open CodeImage with hover underline</Link>
		</div>
	);
}

The default has no underline. variant="underline" adds an underline on hover only. There are no color, size, pill, loading, or icon-slot props. Place decorative icons in the children.

States

Disabled

link/disabled.tsx
import { Link } from "@codeui/solid";

export default function Demo() {
	return (
		<Link href="https://codeimage.dev" disabled>Export history unavailable</Link>
	);
}

disabled prevents activation and removes the control from the tab order. Kobalte removes the destination from a disabled anchor and sets aria-disabled.

Ready API

Link renders a styled Kobalte link.

Prop

Type

The package root exports Link but does not export its props type. The table derives its props from the public component.

Inherited from Kobalte's link contract:

Prop

Type

Accessibility

Keyboard

KeyAction
Tab or Shift+TabMoves focus between enabled controls.
EnterFollows the focused link.

ARIA

The anchor with href has native link semantics. Disabled links expose aria-disabled and data-disabled. The visible text supplies the accessible name. Hide decorative icons from assistive technology. Choose link text that describes the destination. Include new-tab behavior in the label when relevant.

Focus

The kit Link styles remove the outline and do not add a focus-visible ring. Supply a visible focus style in your app until the kit fixes this gap. These controls do not open an overlay or move focus on their own. If your handler opens or closes an overlay, that overlay owns focus placement and restoration.

SSR notes

The root and its children render on the server. There is no portal or client-only mount step in Link. Event handlers become active after hydration. Keep the initial props equal on the server and client.

Theming hooks

Link.css.ts reads no --cui-* variables. It inherits color and line height. Override its class for app-specific text and focus styles.

Composition examples

link/composition.tsx
import { Link } from "@codeui/solid";

export default function Demo() {
	return (
		<div style={{ display: "flex", "flex-wrap": "wrap", gap: "var(--cui-space-3)", "align-items": "center" }}>
			<Link as="a" href="https://github.com/riccardoperra/codeui" target="_blank" rel="noopener noreferrer" variant="underline">View source in a new tab</Link>
		</div>
	);
}

as can select a router component that forwards anchor props. This example uses an explicit anchor and includes rel for a new-tab destination.

  • Button provides a visible action label.
  • IconButton provides a compact named action.
  • Link provides inline navigation.
  • Tooltip explains an icon action on hover and focus.

On this page