# Link

An always-underlined navigation link with default or subtle emphasis. Render an anchor directly, or use asChild to style a router adapter while preserving its link behavior.

**Dependencies:** npm: 2 direct, 3 total; registry: 2 direct, 2 total.

Native: iOS stable, Android stable.

## Usage

### When to use

- Navigate to a page, resource or section from text.
- Place an underlined destination within a sentence.

### When not to use

- An action that changes the current page without navigating. Use Button.
- A path through parent pages. Use Breadcrumb.

### Native

**Default**

```text
WerewolfLink(action: { }) { Text("Read the docs") }
```

```text
WerewolfLink(onClick = { }) { Text("Read the docs") }
```

**Subtle**

```text
WerewolfLink(variant: .subtle, action: { }) { Text("Terms") }
```

```text
WerewolfLink(variant = WerewolfLinkVariant.Subtle, onClick = { }) { Text("Terms") }
```

## Variants

### variant

default uses accent text; subtle uses secondary text.

Values: `default`, `subtle`. Default: `default`.

## Examples

### Inline navigation

```tsx
<p className="text-sm text-text-primary">
  <span>Read the </span>
  <Link href="#installation">installation guide</Link>
  <span> before creating your first theme.</span>
</p>
```

### External destination

```tsx
<Link external href="https://example.com/guide" target="_blank" rel="help">Open the guide</Link>
```

### Composed link

A single child provides the destination. Use the same composition with an application router adapter.

```tsx
<Link asChild variant="subtle">
  <a href="#project">View project</a>
</Link>
```

## Do and don't

### Do

- Use meaningful destination text.
- Use asChild for router adapters with their own destination props.
- Make opening a new tab an explicit choice with target="_blank".

### Don't

- Do not use Link for actions that do not navigate; use Button.
- Do not use external as a substitute for target.
- Do not nest anchors.

## Props

| Name | Type | Values | Default | Description |
| --- | --- | --- | --- | --- |
| `variant` | `enum` | `default`, `subtle` | `default` | default uses accent text; subtle uses secondary text. |
| `external` | `boolean` |  | `false` | Adds a decorative external-link icon. Does not change the target. Not generated for iOS and Android. |
| `asChild` | `boolean` |  | `false` | Styles a single child link or router adapter without a nested anchor. Not generated for iOS and Android. |
| `href` | `string` |  |  | Destination for the native anchor. A child router adapter may supply its own destination. Not generated for iOS and Android. |
| `target` | `string` |  |  | Native navigation target. _blank merges noopener and noreferrer into rel. Not generated for iOS and Android. |
| `rel` | `string` |  |  | Relationship values. Existing values are retained when safe values are added for _blank. Not generated for iOS and Android. |
| `onPress` | `function` |  |  | Native only: called when the link is pressed. The app decides how to open the destination. Only on iOS, Android. |
| `icon` | `node` |  |  | Native only: an optional trailing icon, in the link icon color. Only on iOS, Android. |

### Slots

| Name | Required | Description |
| --- | --- | --- |
| `children` | yes | Visible destination name, or the single child link when asChild is true. |

## Anatomy

| Part | Description |
| --- | --- |
| `root` | Anchor or caller-supplied link with an underline and visible keyboard focus. |
| `icon` | Decorative external-link icon, present only when external is true. |

## Accessibility

Role: `link`

| Keys | Action |
| --- | --- |
| `Tab` | Focus the link. |
| `Enter` | Follow the focused link. |

- Both variants keep an underline so the link is distinguishable without color alone.
- The external icon is decorative and does not change the accessible name.
- external does not force a new tab. An explicit target="_blank" adds noopener noreferrer without dropping existing rel values.
- asChild preserves the child destination, native attributes, event handlers and ref.

## Install

```bash
npx werewolf-ui add link
```

Run `npx werewolf-ui init` once in your app before adding components. Init sets up tokens, their CSS import and agent rules. Add installs this component and its dependencies while preserving your theme. See [Installation](https://www.werewolf-ui.dev/docs/installation.md) for requirements and the alternative registry setup.

```bash
npx werewolf-ui add link --platform ios
npx werewolf-ui add link --platform android
```

For iOS and Android, run `npx werewolf-ui init --platform ios` or `npx werewolf-ui init --platform android` once, then add with `--platform`. See [Installation](https://www.werewolf-ui.dev/docs/installation.md).
