React component that clamps the content of an element by adding an ellipsis to it if the content inside is too long.
It uses @clampy-js/clampy library (a fork of Clamp.js) behind the scene to apply the ellipsis.
It automatically re-clamps itself when the element or the browser window change size.
npm install --save @clampy-js/react-clampy
import React, { Component } from 'react'
import Clampy from '@clampy-js/react-clampy'
class Clampy extends Component {
render () {
return (
<Clampy clampSize="2">My long text to clamp</Clampy>
)
}
}
MIT © alexandremoore