Install from NPM:
yarn install react-text-trimmer
lines
: number of lines to truncate text
prefix
: prefix to attach to beginning of text, default is empty string
suffix
: suffix to attach to end of text, default is ...
interval
: dobounce interval, default is 166
There is two ways to use the text trimmer. One can use the component or the react hook.
Props:
options
: TextTrimmerOptions
import TextTrimmer from "react-text-trimmer"
...
<TextTrimmer>
Long text.........
<TextTrimmer>
...
import { useTextTrimmer } from "react-text-trimmer"
...
const ref = React.useRef(null)
const value = useTextTrimmer(text, ref, options)
return <div ref={ref}>{value}</div>
...
This repository is configured with EditorConfig.