How a page appears when shared, as a search result and social card, with a width meter.
<div class="cap-serp" role="group" aria-label="Search result preview" id="sp-serp">
<p class="cap-serp-url">example.com › blog › why-the-editor-waits</p>
<p class="cap-serp-title">Why the editor waits before it publishes</p>
<p class="cap-serp-description">A failing required check blocks a publish, and a held one says who holds it and until when. Here is what the wait buys.</p>
</div>
<div class="cap-serp" role="group" aria-label="Search result preview" id="sp-serp-cut">
<p class="cap-serp-url">example.com › blog › why-the-uptime-strip-counts-gaps</p>
<p class="cap-serp-title">Why the uptime strip counts gaps and does not average them away in the …</p>
<p class="cap-serp-description">An average of 99.9 percent hides a four hour hole. The strip draws each gap, so the hole is the first thing you see …</p>
<p class="cap-serp-note">Title and description will be truncated. The limits are approximate: search engines cut by pixel width, not by character count.</p>
</div>
Social card
<div class="cap-og-card" role="group" aria-label="Social card preview" id="sp-og">
<div class="cap-og-card-image">
<svg viewBox="0 0 1200 630" role="img" aria-label="The post's cover: a rising line over a grid"><rect width="1200" height="630" fill="oklch(0.55 0.12 300)"/><path d="M60 520 L300 400 L520 450 L760 250 L1140 120" fill="none" stroke="#fff" stroke-width="14" stroke-linecap="round" stroke-linejoin="round"/></svg>
</div>
<div class="cap-og-card-body">
<p class="cap-og-card-host">example.com</p>
<p class="cap-og-card-title">Why the editor waits before it publishes</p>
<p class="cap-og-card-description">A failing required check blocks a publish. Here is what the wait buys.</p>
</div>
</div>
Social card with a note, no description, in a narrow space
<div class="share-preview-narrow-box">
<div class="cap-og-card" role="group" aria-label="Social card preview" id="sp-og-note">
<div class="cap-og-card-image">
<svg viewBox="0 0 600 600" role="img" aria-label="The site mark, used because this post has no cover"><rect width="600" height="600" fill="oklch(0.9 0.02 300)"/><circle cx="300" cy="300" r="120" fill="oklch(0.55 0.12 300)"/></svg>
</div>
<div class="cap-og-card-body">
<p class="cap-og-card-host">example.com</p>
<p class="cap-og-card-title">A title long enough to wrap onto a second line in a narrow card</p>
</div>
<p class="cap-og-card-note">No cover set, so this shares as the site mark. A generated card may still replace it.</p>
</div>
</div>
Width meters: a title that fits, and one Google cuts off
<div data-mount="width"></div>
API reference
SerpPreview
Prop
Type
Required
Does
url
string
Yes
The address as a search result writes it: "example.com › blog › post".
title
ReactNode
Yes
description
ReactNode
Yes
note
ReactNode
Said under the result, for example that the title will be cut.
label
string
OgCardPreview
Prop
Type
Required
Does
image
ReactNode
Yes
An img (alt text set by the app) or an svg. Drawn in a box at the card's 1200 x 630 shape.
host
string
Yes
title
ReactNode
Yes
description
ReactNode
note
ReactNode
Said under the card, for example that the site mark stands in for a missing cover.
label
string
SerpWidthMeter
Prop
Type
Required
Does
label
ReactNode
Yes
The meter's name: "Search title width".
text
string
Yes
The text as the result will show it.
part
SerpPart
Which part of a result it is: its font and limit. Default "title".
limit
number
The width past which it is cut, in pixels. Default Prelum's for the part.
measure
(text: string) => number | null
A width of the app's own (a canvas measure in the real font): null while measuring. Default Prelum's serpWidth, which needs no browser, so a server render shows the number.
size
"sm" | "md" | "lg"
Functions
Function
Signature
Does
serpTextWidth
(text: string, part: SerpPart): number
The text's width in whole pixels, from Arial's advance widths at the part's size.
serpReading
(text: string, px: number | null, limit: number): SerpReading
The meter's words for a width. px null is still being measured.
Parts and data attributes
Class
Is
.cap-og-card
its own class
.cap-og-card-body
its own class
.cap-og-card-description
its own class
.cap-og-card-host
its own class
.cap-og-card-image
its own class
.cap-og-card-note
its own class
.cap-og-card-title
its own class
.cap-serp
the root
.cap-serp-description
a part
.cap-serp-note
a part
.cap-serp-title
a part
.cap-serp-url
a part
Accessibility
Nothing in a preview takes focus. The page's order is the reading order.
Text is --text, --muted and --accent-text on --surface; each pair is in the contrast report.
The card image must carry its own alt text. When the image is a stand-in, say so in the alt text and in the note, as the site admin does.