Skip to content

Latest commit

 

History

History
55 lines (40 loc) · 1.97 KB

File metadata and controls

55 lines (40 loc) · 1.97 KB

Link (type: "link") (dl2 0.4+)

A navigation element: jump to any visual in the report (across pages and tabs), or open an external URL. Renders as an inline link or a button.

Class: dl2_reports.Link · Legacy helper: row.add_link(...) · Example: 15_links_and_modals.py

Quick start

from dl2_reports import Link

page.add_row(
    Link(target_id="sales-table", label="Jump to data", link_style="button"),
    Link(href="https://example.com/docs", label="External docs"),
)

Parameters

Exactly one of target_id / href is required — the constructor raises ValueError otherwise.

Parameter Type Description
target_id str Id of a visual to navigate to. The viewer switches to the containing page, activates containing tabs (nested included), scrolls to the visual, and flashes it.
href str External URL — opens in a new tab.
label str Link text (viewer falls back to the target/href).
link_style str 'link' (viewer default) or 'button'.
extra dict Passthrough props.
**common Common visual properties.

Anchors and deep links

Every visual with an id is also a DOM anchor. Plain #visual-id hash links navigate the same way a Link does — from markdown cards, or as a deep link in the report URL on page load:

report.html#sales-table

Notes

  • Give link targets stable, unique ids — duplicate ids break navigation (and persistence); the viewer's validator warns about them.
  • The compile lint / viewer validation warns when a target_id doesn't resolve to any visual.

Related

  • Tabs — links activate containing tabs automatically.
  • Modal button — open an overlay instead of navigating.