Truncation Preview

Truncation Preview is a copy-paste React component that stops hook hidden behind "…more" before the user submits. It installs via the shadcn CLI, integrates with React 19 and Tailwind CSS, and provides accessible validation cues while keeping authorization on the server.

pnpm dlx shadcn@latest add @bollard/truncation-preview
Version 0.1.0Last updated Free & MIT licensed
  • Styled · shadcn theme
  • React 19+
  • MIT licensed
  • Tailwind v4
  • 1 extra npm package
  • A11y guidance in docs

StopsHook hidden behind "…more"

Was this component page useful?

How do I install Truncation Preview?

pnpm dlx shadcn@latest add @bollard/truncation-preview

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

How do I use Truncation Preview in React?

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

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

What input mistakes does Truncation Preview catch?

  • 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

What props does Truncation Preview accept?

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.

How is Truncation Preview accessible?

  • 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.

What are the limitations and server boundaries?

  • 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 expensive mistakes does Truncation Preview stop?

Hook hidden behind "…more"

Also known as

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

Field type

What dependencies does Truncation Preview require?

Truncation Preview facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameTruncation Preview
Registry identifier@bollard/truncation-preview
Install commandnpx shadcn@latest add @bollard/truncation-preview
LicenseMIT License (free, commercial-friendly)
Price$0 (100% Free and Open Source)
Version0.1.0
RequirementsReact 19+, Tailwind CSS v4, shadcn CLI
SSR supportFully compatible (SSR & Server Components safe, client-hydrated controls)
Dependencieslucide-react
AccessibilityWAI-ARIA compliant, keyboard navigability and screen-reader announcements verified
Last updated2026-10-16
Scope limitationClient-side guardrails catch honest mistakes in the browser; they do not replace server-side validation, database constraints, or backend authorization.

Frequently asked questions about Truncation Preview

What form validation mistake does Truncation Preview catch?

Truncation Preview prevents hook hidden behind "…more". 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. 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. Limitation: validate truncation-preview schemas on backend.

How do I install truncation-preview with shadcn?

Run `npx shadcn@latest add @bollard/truncation-preview`. Sources added: registry/default/truncation-preview/truncation-preview.tsx, registry/default/truncation-preview/truncation.ts. Package requirements: lucide-react.

What props customize Truncation Preview?

Truncation Preview accepts `label`, `value`, `defaultValue`, `onValueChange`, `keyPoint`. Configures linkedin post, instagram caption, tweet behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of truncation-preview?

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 Server requirement: backend verification for truncation-preview.

How does Truncation Preview meet accessibility guidelines?

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. Minimizes errors: linkedin see more cut, instagram caption truncated.

Which components pair with Truncation Preview?