1.1.0 • Published 2 years ago

show-more-less v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

ShowMoreLess

React library to manage long paragraphs

NPM JavaScript Style Guide

Install

npm install --save show-more-less

Usage

import React, { useState } from 'react'
import styles from './ShowMoreLess.module.scss'
import ShowLessMore from 'show-more-less'
import 'show-more-less/dist/index.css'

function Example() {
  const text =
    '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 (
    <ShowLessMore
      text={text}
      threshold={800}
      expanded={expanded}
      onExpand={setExpanded}
      classes={{
        root: styles.root,
        text: styles.text,
        clickable: styles.clickable
      }}
    />
  )
}

export default Example

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