A hook to use CSS property, `line-clamp`, for the long text.
npm install use-dotdotdotA 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.
``
npm install use-dotdotdot
or
yarn add use-dotdotdot
`
| 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 |
`jsx
import { useDotdotdot } from 'use-dotdotdot';
const App = () => {
const { wrapperProps, clampText } = useDotdotdot({ maxLines: 2 });
return (
or use
useDotdotdot` create your own Component