Link¶
Navigate with a validated internal or external anchor.
| Import | from hedron import Link |
| Distribution | hedron |
| Backend activity | No |
| Normal render mode | RenderMode.FRAGMENT |
Live demo¶
The preview is a local docs simulation (not a running Hedron server). Interactive demos show a “Simulated HTMX” trace when applicable.
Basic use¶
Compose under Page for full documents, or return from a fragment route for HTMX swaps.
How it works¶
URLs pass through Hedron's SafeUrl navigation policy. External links receive target=_blank and rel=noopener noreferrer; internal links remain ordinary same-context anchors and work without JavaScript.
This component's core behavior is server-rendered HTML and does not require a browser runtime. The preview is ordinary semantic HTML, so keyboard, form, link, and disclosure behavior comes from the platform.
Constructor and parameters¶
| Parameter | Type | Meaning |
|---|---|---|
label |
str |
Visible link text. |
href |
SafeUrl | str |
Validated navigation URL. |
external |
bool |
Allow an external URL and open it defensively in a new tab. |
Composition and backend behavior¶
Keep Link at the smallest semantic boundary. Fragment routes should return only
the replaced region and preserve stable target IDs across success, validation, empty,
loading, and error responses.
This component is primarily presentational; keep any mutation on an explicit action or component route.
Accessibility¶
Link text should identify the destination out of context; tell users when a destination opens a different site or context if that is not obvious.
Security¶
Escaping and SafeUrl / TrustedHtml are framework concerns; authorization and data
exposure remain application code. Redact secrets before rendering.
Common mistakes¶
- Use LinkButton only for a navigation link that is intentionally styled like a button—do not turn a command into a fake link.
- Do not copy docs-preview JavaScript into an application server.