# use-dotdotdot

> A hook to use CSS property, `line-clamp`, for the long text.

Latest version **1.1.0** (published 2021-01-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install use-dotdotdot
pnpm add use-dotdotdot
yarn add use-dotdotdot
bun add use-dotdotdot
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2021-01-17 |
| First published | 2021-01-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 0 |
| Unpacked size | 40.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Jyun-Han Lin |
| Maintainers | jyunhanlin |
| Keywords | react, react-hook, line-clamp |

## Links

- npm: https://www.npmjs.com/package/use-dotdotdot
- Repository: https://github.com/jyunhanlin/use-dotdotdot
- Homepage: https://github.com/jyunhanlin/use-dotdotdot#readme
- Issues: https://github.com/jyunhanlin/use-dotdotdot/issues
- npm.io page: https://npm.io/package/use-dotdotdot

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2021-01-17
- 1.0.1 — 2021-01-13
- 1.0.0 — 2021-01-02
- 0.1.0 — 2021-01-01

## README

# use-dotdotdot

A hook to use CSS property, `line-clamp`, for the long text.

If only one line, use `text-overflow` for the long text.

If the browser doesn't support `line-clamp` and need multiline text, use the canvas api, `measureText`, to generate clamp text.

## Installation

```
npm install use-dotdotdot

or

yarn add use-dotdotdot
```

## Props

| Name       |         Type         | Description                                             |
| ---------- | :------------------: | ------------------------------------------------------- |
| `width?`   | `string` or `number` | The width of wrapper. If not provide, the width is 100% |
| `maxLines` |       `number`       | How many lines at most                                  |
| `wrapper?` | `React.ElementType`  | Default value is `span`                                       |

## Example

```jsx
import { useDotdotdot } from 'use-dotdotdot';

const App = () => {
  const { wrapperProps, clampText } = useDotdotdot({ maxLines: 2 });

  return (
    <div {...wrapperProps}>
      {clampText(
        'Lorem ipsum dolor sit, amet consectetur adipisicing elit. Ex, deleniti. Ratione voluptatibus ducimus pariatur ab eaque ut vitae, reprehenderit, fugit corrupti quas impedit eum, aut veniam facilis voluptate commodi non?'
      )}
    </div>
  );
};
```

or use `useDotdotdot` create your own Component

---
_Source: https://npm.io/package/use-dotdotdot · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
