package
Apply gradient effects to text with CSS, inline SVG mask fallback or a solid color as last resort.
npm install text-gradientGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Vanilla js version of javierbyte's – react-textgradient.
Apply gradient effects to text with CSS, inline SVG mask fallback or a solid color as last resort.
Note: Not recommended for large amounts of text, suitable for headlines.
url(#gradient).npm install text-gradient --save@argument element <required> [NodeElement] the element to apply the gradient
@argument options <optional> [Object] Gradient color-stops, direction, text.var TextGradient = require('text-gradient');
var MyGradient = TextGradient(document.getElementById('headline'), {
from : '#B0E537',
to : '#009DE9',
direction : 'right'
});| name | type | default | description |
|---|---|---|---|
| text | String | element.textContent | The text to display |
| from | String (valid color format) | transparent | Gradient's first color-stop |
| to | String (valid color format) | transparent | Gradient's last color-stop |
| direction | String | right | One of `top |
Changes the text contents.
/*
* @argument text <required> [String]
* @return undefined
*/
MyGradient.updateText('Some other catchy headline');Remove the text-gradient effect, references and elements created by the instance (svg container, defs, extra spans to wrap the content, etc).
/*
* @return null
*/
MyGradient = MyGradient.destroy();MIT © Noel Delgado