# Link

- **Section:** Components
- **URL:** https://refast.fastapicloud.dev/docs/components/link
- **Markdown:** https://refast.fastapicloud.dev/docs/components/link.md
- **Source:** https://github.com/idling-mind/refast-docs/blob/main/docs/pages/components/typography/link.py
- **Live examples:** the widgets on this page need a browser; open the URL above to try them.
- **Applies to:** refast 0.12.2

Hyperlink component that renders an `<a>` element with optional external-link
icon and server-side callbacks.

```python
from refast.components import Link

# Simple navigation link
Link("Go to Docs", href="/docs/getting-started")

# External link with icon
Link("GitHub", href="https://github.com", target="_blank", external=True)

# Link with click callback and navigation suppressed
Link(
    "Execute action",
    href="https://example.com",
    on_click=ctx.callback(handle_action, prevent_default=True),
    class_name="text-primary hover:underline",
)
```

[Visit the Refast repository](https://github.com)

[Documentation home](https://refast.fastapicloud.dev/)

target="_self"  external=False  class_name=""

## Props

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `text` | `str` | *(required)* | Visible link text |
| `href` | `str` | *(required)* | Link destination URL |
| `target` | `"_self" \| "_blank" \| "_parent" \| "_top"` | `"_self"` | Where to open the link |
| `external` | `bool` | `False` | Show an external-link icon |
| `on_click` | `Callback \| None` | `None` | Server callback on click |
| `id` | `str \| None` | `None` | Unique element ID |
| `class_name` | `str` | `""` | Extra Tailwind classes |
| `style` | `dict \| None` | `None` | Inline CSS overrides |

## Notes

Use `class_name="underline underline-offset-4"` to match the default link
styling convention. For navigation within the app prefer `href="/<route>"` —
these are handled by the SPA router automatically.

To execute Python or JavaScript actions from a `Link` without navigating away from the page, pass `prevent_default=True` when creating the callback (e.g., `on_click=ctx.callback(handle_action, prevent_default=True)`).

---

Part of the Refast documentation: [all pages](https://refast.fastapicloud.dev/llms.txt), [everything on one page](https://refast.fastapicloud.dev/llms-full.txt), [search](https://refast.fastapicloud.dev/api/search?q=save_prop).
