Using the ReadMore component is a simple way to keep longer content from cluttering up your page, giving you more control over how much content is displayed to visitors.
import { ReadMore } from "@wfp/react"
Based on the type of content use react-truncate or react-truncate-html to truncate the collapsed content.
import Truncate from "react-truncate";
<ReadMorecollapsed={<Truncate lines={1} ellipsis="...">{moreText}</Truncate>}>Expanded content</ReadMore>
The maxHeight
prop will allow the content to be collapsed if it extends a specific height. It will only work without the collapsed
prop.
<ReadMore fade maxHeight={30}>The content</ReadMore>