Link preview

A URL drawn as a card from metadata the host already fetched: title, description, image, site, favicon, author and date. Presentation only; it fetches nothing.

Anatomy

 ┌───────────────────────────────────────────┬────────┐
 │ ◉ Example · example.com                   │        │ ← meta row: favicon, site, domain
 │ The page's title, at most two lines       │  img   │ ← title (the link's name)
 │ Its description, at most two lines        │        │ ← description (the link's description)
 │ Ada Lovelace · 3 Dec 2026                 │        │
 └───────────────────────────────────────────┴────────┘   row; card puts the image on top
 [◉ Title · example.com]                                   compact
PartTokenWhy
Cardsurface, border, rounded-panel; hover:bg-surface-subtleA panel among panels; the hover says the whole of it is one target.
Titletext-body font-semibold text-fg, line-clamp-2The link's name, held so a long one cannot grow the card.
Descriptiontext-body text-fg-muted, line-clamp-2Secondary to the title.
Metatext-meta text-fg-muted
Image framesurface-subtle, a photo icon behind the imageA failed image (with alt="" it draws nothing) leaves the frame and icon: no script, no onerror.
Imageaspect-[1.91/1] on a card (the Open Graph shape), a square w-24/w-28 in a row

URL safety

The URL is someone else's data. Control characters and leading whitespace are cut as a browser would, then only http and https with a host become an <a>; anything else (javascript:, data:, vbscript:, a relative path) is drawn as the same card in a div, its text shown. Images and favicons are allowed with no scheme (the host's own path), http(s), or data:image/; anything else is dropped. Every image carries referrerpolicy="no-referrer". The domain is the host without www..

The server-side fetch is the host's, and its rules (refuse private addresses after every redirect, bound time and size, proxy the image, cache by URL) are in the docs page, as prose: the component has nothing to enforce them with.

States

  • loading: inside ds::skeleton-swap :loaded="false", a skeleton shaped like the variant; the host swaps in the real one.
  • failed: a plain link (link icon + domain), or text when the URL is unsafe.
  • dismiss: the root takes dsDismiss (the announcement bar's): a ✕ after the link, shown once the script has started (in-data-[ds-state]:visible), which marks the root dismissed (data-[ds-state=dismissed]:hidden) and dispatches dismiss. No new script.

Accessibility

  • Role and name: one link, aria-labelledby the title, the domain and, with target="_blank", a visually hidden ", opens in a new tab"; aria-describedby the description. The meta row is not in the name.
  • Images: alt=""; the title says what the link is.
  • Keyboard: the link, then the ✕ (a separate button, never inside it).
  • Focus: outline-focus-ring on the card.

Do not

  • Build the href in the view without the check, or print the URL raw.
  • Put the ✕ inside the link. A button in a link is invalid and its press follows the link.
  • Hot-link a stranger's image where it can be proxied; the docs say why.

From the package repo: edit this page on GitHub.

Was this page helpful?