JB logo

Command Palette

Search for a command to run...

yOUTUBE
Blog
PreviousNext

Middle Truncation

Truncate text in the middle while preserving start and end.

Loading...

Installation

pnpm dlx shadcn@latest add https://jb.desishub.com/r/middle-truncation.json

Usage

import { MiddleTruncation } from "@/components/middle-truncation";
<MiddleTruncation>
  /Users/jb/Code/portfolio/src/components/ui/button.tsx
</MiddleTruncation>

Props

PropTypeDefaultDescription
childrenstring-The text content to truncate.
endnumber-Fixed number of characters to preserve at the end.
minEndnumber-Minimum characters at the end when splitting evenly.
ellipsisstring"..."Custom ellipsis string.