Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-line-clamp

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-line-clamp

A react component which can help you implememt line-clamp automatically

  • 1.2.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
49
increased by1533.33%
Maintainers
1
Weekly downloads
 
Created
Source

react-clamp

A React Component which can help you clamp Multi-line text.

Getting Started

  • Install with npm: npm install react-line-clamp
  • Clone the repo: https://github.com/oglen/react-clamp

Usage

  1. require react-clamp to your react component:

     import Clamp from 'react-line-clamp';
    
  2. Use react-clamp in your component:

     class Component extends React.Component {
    
         componentDidMount() {
             window && window.addEventListener('resize', event => {
                 this.refs.aCard.adjustContext();
             });
         }
    
         render() {
             return <div className="container">
                 <div className="grid" id="demo">
                     <div className="column">
                         <Clamp className="card" ellipsis="..." ref="aCard" option={{autoAdjustInterval: 0}} >
                         Brisbane’s Waterfront Place and the Eagle Street Pier retail complex were snapped up by property giant Dexus Property Group and Dexus Wholesale Property Fund for a staggering $635 million.
                         </Clamp>
                     </div>
                     <div className="column">
                         <Clamp className="card" ellipsis={<span>&nbsp;<a href="#">Read More</a></span>} ref="bCard">
                         Brisbane’s Waterfront Place and the Eagle Street Pier retail complex were snapped up by property giant Dexus Property Group and Dexus Wholesale Property Fund for a staggering $635 million.
                         </Clamp>
                     </div>
                 </div>
             </div>
         }
    
         ...
     }
    

    In default, the option is {autoAdjustInterval: 200}, it will ensure adjusting is automatic.

  3. And set the card style:

     .card {
       height: 60px;
       overflow: hidden;
       line-height: 20px;
     }
    

Run Demo

There is a clear and concise example in the repo, preview it in following steps:

Enter the project fold and execute:

npm install
gulp

And visit link:

/demo/index.html

Keywords

FAQs

Package last updated on 30 Oct 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc