npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@cloud-ru/ds-truncate-string

v1.0.12

Published

Обрезает длинный текст и показывает полный текст в тултипе — варианты `end` и `middle`, поддержка многострочного обрезания.

Readme

TruncateString

@cloud-ru/ds-truncate-string — Обрезает длинный текст и показывает полный текст в тултипе — варианты end и middle, поддержка многострочного обрезания.

Обрезает длинный текст в ограниченной по ширине области и раскрывает полный вариант в тултипе при наведении. Два варианта обрезания — с конца (end) и посередине (middle) — решают разные задачи: читаемый заголовок и распознаваемое имя файла соответственно.

Когда использовать

  • В списках, таблицах и карточках, где ширина ячейки зафиксирована.
  • Для имён файлов, идентификаторов и коммитов — чтобы сохранить начало и конец строки (middle).
  • Для заголовков и описаний, длина которых непредсказуема.

Когда не нужен: если контейнер может расти по содержимому (например, body статьи) — проще обернуть текст в абзац без обрезания.

Анатомия

Variant

Где обрезается строка: end — троеточие в конце (стандартный CSS ellipsis), middle — обрезка посередине (для путей, email, ID — чтобы видеть начало и конец).

Установка

pnpm add @cloud-ru/ds-truncate-string
import { TruncateString } from '@cloud-ru/ds-truncate-string'

Примеры использования

Обрезание с конца

import { TruncateString } from '@cloud-ru/ds-truncate-string';

export function TruncateEnd() {
  return (
    <div style={{ width: 220 }}>
      <TruncateString variant='end' text='Очень длинный заголовок, который не помещается' maxLines={1} />
    </div>
  );
}

Обрезание посередине — имя файла

import { TruncateString } from '@cloud-ru/ds-truncate-string';

export function TruncateMiddle() {
  return (
    <div style={{ width: 220 }}>
      <TruncateString variant='middle' text='2024-quarterly-report-final-v3.pdf' />
    </div>
  );
}

Многострочное описание

import { TruncateString } from '@cloud-ru/ds-truncate-string';

export function TruncateMultiline() {
  return (
    <div style={{ width: 260 }}>
      <TruncateString
        variant='end'
        maxLines={3}
        text='Длинное описание, которое укладывается в три строки, а затем обрезается с троеточием в конце.'
      />
    </div>
  );
}

Props

TruncateStringProps

| Prop | Type | Default | Description | |------|------|---------|-------------| | className | string | — | | | data-test-id | string | — | | | hideTooltip | boolean | — | Скрывать ли тултип с полным текстом | | maxLines | number | — | Максимальное кол-во строк, до которого может сворачиваться текст. | | placement | "bottom" | "bottom-end" | "bottom-start" | "left" | "left-end" | "left-start" | "right" | "right-end" | "right-start" | "top" | "top-end" | "top-start" | — | Положение тултипа относительно обрезанного текста. | | text | string | — | Текст, который будет обрезаться | | tooltipClassName | string | — | Стиль для тултипа | | trigger | "click" | "clickAndFocusVisible" | "focus" | "focusVisible" | "hover" | "hoverAndFocus" | "hoverAndFocusVisible" | — | Условие отображения тултипа | | variant | "end" | "middle" | end | Вариант обрезания строки: End - с конца Middle - по середине |