Skip to content

Repository files navigation

ShowMoreLess

React library to manage long paragraphs

NPMJavaScript Style Guide

Install

npm install --save show-more-less

Usage

importReact,{useState}from'react'importstylesfrom'./ShowMoreLess.module.scss'importShowMoreLessfrom'show-more-less'import'show-more-less/dist/index.css'functionExample(){consttext='Lorem ipsum dolor sit amet consectetur adipisicing elit. Accusamus dolores, cumque tenetur omnis debitis eligendi illum adipisci. Amet, ex soluta. Consequatur ab minus voluptates illum exercitationem, repellat perferendis iure possimus.'const[expanded,setExpanded]=useState(false)return(<ShowMoreLesstext={text}threshold={800}expanded={expanded}onExpand={setExpanded}classes={{root: styles.root,text: styles.text,clickable: styles.clickable}}/>)}exportdefaultExample

Table of contents

Type aliases

Type aliases

ClassesObject

Type declaration

NameTypeDescription
clickable?stringstyle class at the show more/less text level
root?stringstyle class at the root level
text?stringstyle class at the text level

OnExpand

Type declaration

▸ (value): void

Parameters
NameTypeDescription
valuebooleanThis is the updated value, passed as a param
Returns

void


ShowMoreLessProps

Type declaration

NameTypeDescriptionDefault
classes?ClassesObjectan optional ClassesObject, for style-
expanded?booleandetermines whether the text is expanded or notfalse
onExpand?OnExpanda callback function called on clicking show more/less text-
showLessLabel?stringlabel text for show more...Show More
showMoreLabel?stringlabel text for show lessShow Less
textstringtext to be shown-
threshold?numbera point after which the text will be trimmed100

License

MIT © iamdipanshusingh

About

No description, website, or topics provided.

Resources

Stars

5 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages