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
| Part | Token | Why |
|---|---|---|
| Card | surface, border, rounded-panel; hover:bg-surface-subtle | A panel among panels; the hover says the whole of it is one target. |
| Title | text-body font-semibold text-fg, line-clamp-2 | The link's name, held so a long one cannot grow the card. |
| Description | text-body text-fg-muted, line-clamp-2 | Secondary to the title. |
| Meta | text-meta text-fg-muted | |
| Image frame | surface-subtle, a photo icon behind the image | A failed image (with alt="" it draws nothing) leaves the frame and icon: no script, no onerror. |
| Image | aspect-[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 dispatchesdismiss. No new script.
Accessibility
- Role and name: one link,
aria-labelledbythe title, the domain and, withtarget="_blank", a visually hidden ", opens in a new tab";aria-describedbythe 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-ringon 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.