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

water-design-ellipsis

v1.0.4

Published

一个基于react的单行&多行溢出隐藏组件

Readme

综述

该组件适用于 web 环境下的文本溢出,支持:

  • 单行溢出隐藏(设置 width & height 即可)
    • 支持溢出尾部省略隐藏
    • 支持溢出中间部分省略隐藏
  • 多行溢出隐藏(设置 width & height & line 即可)
  • 单行或多行溢出直接截断(设置 defaultDirectCuttrue 即可)
  • 支持溢出时 hover 有 tooltip 提示,移动端不支持 tooltip 提示,默认enableTooltip开启,请合理设置宽高和字体行高。

使用

import React from 'react';
import { createRoot } from 'react-dom/client';
import Ellipsis from 'water-design-ellipsis';
import './index.css';

function App() {
  return (
    <Ellipsis
      className="title"
      tooltipProps={{ textColor: 'pink', className: 'tool-tip' }}
    >
      看花不是花,看雾亦非雾,是宿命还是我糊涂;看岁月晃晃悠悠,不紧不慢拉着我走
    </Ellipsis>
  );
}

const root = createRoot(document.getElementById('root'));
root.render(<App />);
.title {
  width: 300px;
  height: 30px;
  font-size: 24px;
  line-height: 30px;
  background-color: skyblue;
}

.tool-tip {
  width: 260px;
}

API

| 参数 | 说明 | 类型 | 默认值 | 版本 | | :------------------ | :------------------------------------------------------ | :-------------- | :------ | :--- | | className | 自定义类名 | string | - | | | style | 自定义样式对象 | CSSProperties | - | | | defaultDirectCut | 选择文本溢出直接截断,无省略号 | boolean | false | | | middleOverflow | 是否选择中间位置省略 | boolean | | - | | endCharCount | 当一行溢出时,且选择中间省略时,文本尾部字符数 | number | 4 | | | line | 选择文本多少行溢出隐藏, 仅在尾部省略生效 | number | 1 | | | prevTextClassName | 单行溢出省略前文本自定义类名 | string | - | | | nextTextClassName | 单行溢出省略后文本自定义类名 | string | - | | | wordClassName | 直接截断每个字符自定义类名 | string | - | | | prevTextStyle | 单行溢出省略前文本自定义样式对象 | CSSProperties | - | | | nextTextStyle | 单行溢出省略后文本自定义样式对象 | CSSProperties | - | | | wordStyle | 直接截断每个字符自定义样式对象 | CSSProperties | - | | | enableTooltip | 是否开启 tooltip 提示,仅在 PC 端生效 | boolean | true | | | tooltipProps | 提示传入的属性,继承库react-tooltip中的TooltipProps | TooltipProps | - | | | children | 文本 | string | - | |

注:单行溢出外层会嵌套一层盒子,可通过prevTextClassName,prevTextStyle修改内层盒子样式。