Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

midcut

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

midcut

A <1kb React component that accurately middle-truncates monospaced text

latest
Source
npmnpm
Version
0.2.0
Version published
Maintainers
1
Created
Source

midcut

A <1kb React component that accurately middle-truncates monospaced text. Uses CSS round() and container queries (no JS measurement).

Install

npm i -S midcut
pnpm add midcut
bun add midcut

Usage

import { Midcut } from "midcut";

function App() {
  return <Midcut prefix="0x" value="0x1234567890abcdef1234567890abcdef12345678" />;
}

Important: only use with a monospace font.

Props

PropTypeDefaultDescription
valuestring""The string to truncate
prefixstring""A prefix that is always visible (e.g. "0x")
minnumber1Minimum characters visible on each side of the ellipsis
ellipsisstring"…"The ellipsis character(s)
align"start" | "end""start"Alignment of the truncated string within its container

How it works

  • The string is split into two halves displayed as inline flex items
  • A CSS container query activates truncation when the container is narrower than the full string
  • round(down, ..., 2ch) snaps the truncatable width to character boundaries so characters are never partially clipped
  • The end half uses justify-content: flex-end to truncate from the start

Development

bun install
bun dev

License

MIT

Keywords

css

FAQs

Package last updated on 23 Apr 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts