Middle Truncate

Middle Truncate is a copy-paste React component that stops picked the wrong file by prefix 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/middle-truncate
Version 0.1.0Last updated Free & MIT licensed
  • Styled · shadcn theme
  • React 19+
  • MIT licensed
  • Tailwind v4
  • No extra npm packages
  • A11y guidance in docs

StopsPicked the wrong file by prefix

Was this component page useful?

How do I install Middle Truncate?

pnpm dlx shadcn@latest add @bollard/middle-truncate

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

How do I use Middle Truncate in React?

middle-truncate-usage.tsx
import { MiddleTruncate } from "@/components/ui/middle-truncate"

<MiddleTruncate value={item.value} className={item.mono ? "flex-1 font-mono text-[13px]" : "flex-1"} />

What input mistakes does Middle Truncate catch?

  • Lookalike items that differ only at the end
  • File extensions cut off
  • Emoji or accented characters split in half

What props does Middle Truncate accept?

MiddleTruncate props
PropTypeDefault
value* (required)

The full text. It stays available to copy, `title` and screen readers.

string—
minTail

Characters always kept at the end. Defaults to the file extension, or 4.

number—
ellipsis

Marker inserted where text is removed.

string"…"

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

How is Middle Truncate accessible?

  • The full value is in the accessibility tree; the truncated display is aria-hidden
  • Full value is also in the title when truncated
  • Copy puts the full value on the clipboard, not the ellipsis

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

What are the limitations and server boundaries?

  • Measures width in the browser after layout, so server-rendered HTML shows the full value until hydration
  • Very narrow containers may still show only a few characters

What expensive mistakes does Middle Truncate stop?

Picked the wrong file by prefix

Also known as

truncate · ellipsis · wallet address · file name · transaction id · hash · text overflow · web3

Field type

What dependencies does Middle Truncate require?

None beyond React and Tailwind CSS.

Middle Truncate facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameMiddle Truncate
Registry identifier@bollard/middle-truncate
Install commandnpx shadcn@latest add @bollard/middle-truncate
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)
Dependencies0 runtime dependencies
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 Middle Truncate

What form validation mistake does Middle Truncate catch?

Middle Truncate prevents picked the wrong file by prefix. Truncates long names and IDs in the middle at the real rendered width, so the end that tells files or wallets apart stays visible. Catches: Lookalike items that differ only at the end, File extensions cut off, Emoji or accented characters split in half. Limitation: validate middle-truncate schemas on backend.

How do I install middle-truncate with shadcn?

Run `npx shadcn@latest add @bollard/middle-truncate`. Sources added: registry/default/middle-truncate/middle-truncate.tsx. Package requirements: zero dependencies for middle-truncate.

What props customize Middle Truncate?

Middle Truncate accepts `value`, `minTail`, `ellipsis`. Configures truncate, ellipsis, wallet address behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of middle-truncate?

Measures width in the browser after layout, so server-rendered HTML shows the full value until hydration. Very narrow containers may still show only a few characters Server requirement: backend verification for middle-truncate.

How does Middle Truncate meet accessibility guidelines?

The full value is in the accessibility tree; the truncated display is aria-hidden. Full value is also in the title when truncated. Copy puts the full value on the clipboard, not the ellipsis. Minimizes errors: truncated wallet address, file names cut off.

Which components pair with Middle Truncate?