# Skip link

The first focusable element of a page, visible on focus, that jumps to the main content.

- Family: navigation
- Import: `import { SkipLink } from "@senvenli/react/navigation";`
- Page: https://design.senvenli.com/docs/components/skip-link
- JSON: https://design.senvenli.com/docs/components/skip-link.json

## Example: Skip to the main content

Hidden until it has keyboard focus: press the button, then Tab.

```tsx
import { Button, Link } from "@senvenli/react/action";
import { Text } from "@senvenli/react/display";
import { Stack } from "@senvenli/react/layout";
import { SkipLink } from "@senvenli/react/navigation";

export default function Example() {
  return (
    // Demo frame only: `contain-layout` keeps the focused link inside this box, and the button gives Tab a
    // place to start. In an app, SkipLink is the first element in <body> and targets the page's <main>.
    <div className="rounded-ds-large border border-ds-border p-ds-300 pt-ds-800 contain-layout">
      <Stack space="space-200">
        <Stack direction="horizontal" space="space-200">
          <Button>Start here, then press Tab</Button>
          <SkipLink target="#skip-link-example-content" />
          <Link href="#">Orders</Link>
          <Link href="#">Customers</Link>
          <Link href="#">Invoices</Link>
        </Stack>
        <div id="skip-link-example-content">
          <Text tone="subtle">Main content: the skip link moves focus here, past the links above.</Text>
        </div>
      </Stack>
    </div>
  );
}
```

## Guidelines

### When to use it

- Every page with navigation before the main content.

### Use something else when

- [link](https://design.senvenli.com/docs/components/link.md): The link is part of the visible navigation.

## Accessibility

Built in:

- Shown only while focused; named "Skip to content".

You provide:

- An id on the main content it targets.

## API reference

### SkipLink

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| target | `string` | `"main"` | no | Where focus goes: the page's main region by default. |
| children | `React.ReactNode` |  | no | "Skip to content" by default. |

### Tokens it reads

`--ds-border-focused`, `--ds-radius-medium`, `--ds-shadow-overlay`, `--ds-space-100`, `--ds-space-150`, `--ds-space-200`, `--ds-surface-overlay`, `--ds-text`
