Lifetime updates on every purchase Support replies within 24 hours Secure checkout via Gumroad 8,500+ sales since 2016

Script tag

Updated 1 min read 1 view

Copy dist/smooth-background.min.js to your project:

<script src="smooth-background.min.js"></script>
<script>
new SmoothBackground('.hero', { colors: ['#D4E66A', '#B6CEDD', '#2A3240'] });
</script>

The browser build exposes window.SmoothBackground and automatically initialises every element that has a data-sbg attribute (see Data attributes).

ES module

import SmoothBackground from './smooth-background.esm.js';

Bundlers (CommonJS / ESM)

Put the package folder into your project (or publish it to your private registry) and import it:

import SmoothBackground from 'vlt-smooth-background';
// or
const SmoothBackground = require('vlt-smooth-background');
FileFormat
dist/smooth-background.min.jsBrowser, minified, auto-init
dist/smooth-background.jsBrowser, readable, auto-init
dist/smooth-background.esm.jsES module
dist/smooth-background.cjsCommonJS
dist/smooth-background.d.tsTypeScript definitions
Was this article helpful?