Package Exports
- twallpaper
- twallpaper/dist/twallpaper.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (twallpaper) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
🌈 Multicolor gradient wallpaper created algorithmically and shimmers smoothly.
Features
- 🔥 Zero dependencies
- ⚙️ Flexible configuration
- 📦 Lightweight (~2.5kB gzipped)
- 📜 Supports TypeScript type definition
Browsers support
![]() Edge / IE |
![]() Firefox |
![]() Chrome |
![]() Safari |
![]() iOS Safari |
![]() Opera |
![]() Yandex |
|---|---|---|---|---|---|---|
| ✔ , IE11 (partial) | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
Installation
# with npm:
npm install twallpaper
# or yarn:
yarn add twallpaperDemo
You can play with twallpaper on twallpaper.js.org
Usage
import { TWallpaper } from 'twallpaper'
const container = document.querySelector('.tw-wrap')
const wallpaper = new TWallpaper(container, { /* options */ })Using CDN
<!-- JSDelivr -->
<script src="https://cdn.jsdelivr.net/npm/twallpaper@latest/dist/twallpaper.js"></script>
<!-- UNPKG -->
<script src="https://unpkg.com/twallpaper@latest/dist/twallpaper.js"></script>API
.init(options)
Re/initilize animation (before reinitializing, calls the dispose() method).
options
Type: TWallpaperOptions and Container
.animate(start?)
Start/stop animation.
start
Type: boolean
Default: true
.scrollAnimate(start?)
Start/stop mouse scroll animation.
start
Type: boolean
Default: false
.toNextPosition(callback?)
Next animation position (animation turns off after use).
callback
Execution toNextPosition is finished.
Type: function
.updateColors(colors)
Force update colors.
colors
Type: string[]
.updateFrametime(fps?)
Force update frametime.
fps
Type: number
Default: 30
.updatePattern(pattern)
Force update pattern options.
pattern
Type: PatternOptions
.updateTails(tails?)
Force update tails speed.
tails
Type: number
Default 90
.dispose()
Destroy the instance wallpaper.
Options
| Key | Type | Default | Description |
|---|---|---|---|
| colors | string[] | Colors for gradient, use 1-4 full hex codes. This parameter is enough to make the fantastic gradient work. | |
| fps | number | 30 | Frame time is just the time between frames. |
| tails | number | 90 | Tail speed animation. |
| animate | boolean | true | The main parameter responsible for the operation of the animation. |
| scrollAnimate | boolean | false | The animation is tied to scrolling with the mouse wheel. |
| pattern | PatternOptions | Pattern options. | |
| pattern.image | string | Wallpaper image. Use standard pattern or create your own. | |
| pattern.mask | boolean | false | Option enables a mask for the background image using the mask-image css-property. |
| pattern.background | string | #000 | Specify the mask color in hex format. Background does not work when mask is enabled. |
| pattern.size | string | auto | Image background size. |
| pattern.blur | number | 0 | Applies to the pattern image. Blur does not work when mask is enabled. |
| pattern.opacity | number | 0.5 | Applies to the pattern image. |






