Truncation Preview

Shows where social feeds and search results cut a post behind "…more", and warns when the key point or a link falls below the fold.

StopsHook hidden behind "…more"

Installation

pnpm dlx shadcn@latest add https://bollard-ui.vercel.app/r/truncation-preview.json

The files land in your project. They're yours to edit.

Usage

truncation-preview-usage.tsx
import { TruncationPreview } from "@/components/ui/truncation-preview"

return <TruncationPreview label="LinkedIn post" defaultValue={POST} defaultKeyPoint="Free for students" />

What it catches

  • Key phrase hidden below the fold on a surface
  • Links hidden behind "…more"
  • Blank lines that each cost a whole preview line
  • An @mention at the start that X won't notify as intended
  • Key phrase missing from the text

Props

TruncationPreview props
PropTypeDefault
label

Visible label of the text field.

string"Post"
value

Controlled text.

string—
defaultValue

Initial text when uncontrolled.

string""
onValueChange

Called on every edit, including one-tap fixes.

(value: string) => void—
keyPoint

The phrase readers must see before "…more", e.g. the offer or the date.

string—
defaultKeyPoint

Starting key phrase when uncontrolled.

string""
onKeyPointChange

Called with the key phrase.

(value: string) => void—
surfaces

Where the text will appear: built-in ids or your own rules.

(SurfaceId | FoldRule)[]["linkedin-mobile", "linkedin-desktop", "instagram", "x",…
rows

Textarea rows.

number6
keyPointLabel

Templates: `{phrase}`, `{where}`, `{mention}`, `{count}`.

string"Must be seen"
keyHiddenText

Warning when the key phrase is below the fold.

string"“{phrase}” is hidden behind “more” on {where}."
linkHiddenText

Warning when a link is below the fold.

string"The link is below the fold on {where}; few people expand…
linesText

Note about blank lines costing preview lines.

string"Blank lines use up the preview on {where}: each costs a …
mentionText

Warning about a leading

string"{mention} comes after X's first 280 characters, so they …
keyMissingText

Warning when the key phrase isn't in the text.

string"“{phrase}” isn't in the text yet."
moveLabel

Label of the move-sentence-up fix.

string"Move it to the start"
tightenLabel

Label of the remove-blank-lines fix.

string"Remove blank lines up top"
hiddenLabel

Label for text below the fold.

string"Hidden: {count} characters"
placesLabel

Accessible name of the places tab list.

string"Where it appears"
hiddenSrText

Screen-reader note on a tab where the key point or link is cut off.

string" (something is hidden)"

* required. Also accepts the native props of <div> (className, aria-*, data-*…), passed through to it.

Accessibility

  • Text and key-point inputs have <label>s
  • Surfaces are a tablist with arrow-key navigation and a tabpanel
  • Hidden content is flagged in text, not colour alone
  • Warnings in a polite live region

Only what the source does. Test with your own screen reader and content before shipping.

Limitations

  • Fold positions are measured approximations; platforms don't publish them and change them
  • Pixel widths depend on fonts and devices
  • Override surfaces for your own targets

What it stops

Hook hidden behind "…more"

Also known as

linkedin post · instagram caption · tweet · see more · seo title · meta description · push notification · character limit

Field type

Dependencies

Pairs well with