---
title: "Link · Ark UI — StyleX Blocks"
description: "Inline anchors with underline and plain hover treatments and a themed focus ring."
url: "https://stylexblocks.com/components/ark-ui/link/"
agent:
  instructions: "Use this search API to find relevant components and blocks across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://stylexblocks.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Link

Inline anchors with underline and plain hover treatments and a themed focus ring.

- Behavior engine: Ark UI
- Also available for: [Base UI](https://stylexblocks.com/components/base-ui/link.md), [UI SDK](https://stylexblocks.com/components/ui-sdk/link.md)
- Category: Typography
- Variants: underline, plain
- HTML page: https://stylexblocks.com/components/ark-ui/link/

## Install

Configure the project once (sets the behavior engine and import aliases):

```sh
npx stylexblocks init
```

Then add the item as source you own:

```sh
npx stylexblocks add link
```

Equivalent: `npx shadcn add @stylexblocks/link`. Registry item JSON: https://stylexblocks.com/r/ark-ui/link.json

## Usage

```tsx
import { Link } from "#components/ui/ark-ui/link.tsx";

export function Example() {
  return (
    <>
      {/* the variant prop resolves through the StyleX recipe */}
      <Link href="/docs" variant="underline">Read the docs</Link>

      {/* composition: asChild forwards everything onto your element,
          e.g. a router's link component */}
      <Link asChild variant="plain">
        <RouterLink to="/pricing">Pricing</RouterLink>
      </Link>
    </>
  );
}
```

## Source

`components/ui/ark-ui/link.tsx`

```tsx
import * as stylex from "@stylexjs/stylex";
import { createComponent } from "#lib/ark-ui/create-component.tsx";
import { defineRecipe } from "#lib/recipe-props.ts";
import { colorPalette } from '@stylexblocks/ui/color-palette.stylex.ts'
import { semanticRadii } from '@stylexblocks/ui/semantic-tokens/radii.stylex.ts'
import { spacing } from '@stylexblocks/ui/tokens/spacing.stylex.ts'

const linkStyles = stylex.create({
  base: {
    display: 'inline-flex',
    alignItems: 'center',
    outline: 'none',
    gap: spacing._1_5,
    cursor: 'pointer',
    borderRadius: semanticRadii.control,
    outlineWidth: {
      default: null,
      ':focus': '1px',
    },
    outlineOffset: {
      default: null,
      ':focus': '2px',
    },
    outlineStyle: {
      default: null,
      ':focus': 'solid',
    },
    outlineColor: {
      default: null,
      ':focus': colorPalette.focusRing,
    },
  },
})

const linkVariants = stylex.create({
  underline: {
    color: colorPalette.fg,
    textDecoration: 'underline',
    textUnderlineOffset: '3px',
    textDecorationColor: 'currentColor/20',
  },
  plain: {
    color: colorPalette.fg,
    textDecoration: {
      default: null,
      ':hover': 'underline',
    },
    textUnderlineOffset: {
      default: null,
      ':hover': '3px',
    },
    textDecorationColor: {
      default: null,
      ':hover': 'currentColor/20',
    },
  },
})

export type LinkVariant = keyof typeof linkVariants

/**
 * Link — recipe and component colocated in one file. The variant prop
 * resolves mechanically from the axis map. Composition via `asChild`.
 */
const linkRecipe = defineRecipe({
  styles: linkStyles,
  axes: { variant: linkVariants },
  defaultVariants: { variant: "plain" },
});

export const Link = createComponent("a", linkRecipe, "Link");

export type LinkProps = React.ComponentProps<typeof Link>;
```
