Skip to content
Agents tracked: 502 Releases (7d): 613 Agent status: 4 with issuesSince last limit reset: Claude 7d · Codex 5d For AI agents: Markdown Updated Nov 18, 2026

Granim.js

by Benjamin Blonde (sarcadass)

Tiny library for fluid animated gradient backgrounds on canvas, with gradient states, image blending and transitions.

Video references and motion backgrounds Code libraryOpen sourcegradientminimal

GitHub repoWebsite
A hero block on a diagonal gradient that cycles through three color pairs, a card with a radial gradient, and a card with three color stops at set positions, each drawn by Granim on a canvas.
Made by AgentGid with granim 2.0.0 (npm, hash checked against the registry). MIT license; the colors are taken from the examples page and the texts are our own placeholders.

2. Commercial use: raw.githubusercontent.com

“to use, copy, modify, merge, publish, distribute, sublicense, and/or sell”

MIT allows use in paid products without a fee.

raw.githubusercontent.com

License checked Nov 5, 2026 against 1 official page. Tap a verdict to see its source. How we checked Report an error

Granim.js: slowly shifting color gradients behind your content

Granim.js is a small free code library that fills a box on a web page with a color gradient that slowly changes from one set of colors to the next. You pick the colors and the direction, and it draws them behind your headline or card. It can also blend the colors with a picture and switch to other colors when a visitor clicks something.

Where you can use it

A moving background for a hero

A moving background for a hero

Put a slowly shifting gradient behind the big headline at the top of a landing page, so the first screen feels alive without a video.

Colors that answer a click

Switch the background to another set of colors when a visitor picks a plan, a mood or a dark theme, with a smooth fade between them.

Colored light over a photo

Lay the moving colors over your own photo with a blend mode such as multiply or screen, for a tinted header picture.

A logo or title filled with moving color

Show the moving gradient only inside a shape, such as your logo or a large word, by placing a cut-out picture over the canvas.

Text that stays readable on any color

Let the library mark the page as dark or light while the colors change, so your styles can switch the text between white and black.

A calm backdrop for a waiting screen Idea

Fill a loading, sign-in or "coming soon" screen with slow color changes, so the empty page looks finished while people wait.

Granim.js popularity

22 / 100
Gid Score, same scale as developer tools
5,295
GitHub stars
3,733
npm downloads, last 7 days
-22.8% in 4 weeks
Granim.js: downloads per weeknpm, granim 3,733
Granim.js: GitHub starssarcadass/granim.js 5,295

Downloads from api.npmjs.org, stars from GitHub, checked Nov 17, 2026. How the Gid Score is calculated

How to start

Tell your AI assistant

“Add granim 2.0.0 to the hero section of my landing page as an animated background on a full-size canvas behind the headline, with three color pairs from my brand, isPausedWhenNotInView set to true, and a still gradient for visitors who prefer reduced motion.”

Or install it yourself.

npm install granim --save
Show code

Add a canvas where the gradient should appear, load the script and create a Granim instance with at least one state of gradients.

<!-- Create a <canvas> element -->
<canvas id="granim-canvas"></canvas>

<!-- Call the script -->
<script src="granim.min.js"></script>

<!-- Create a Granim instance -->
<script>
var granimInstance = new Granim({
   element: '#granim-canvas',
   name: 'granim',
   opacity: [1, 1],
   states : {
       "default-state": {
           gradients: [
               ['#834D9B', '#D04ED6'],
               ['#1CD8D2', '#93EDC7']
           ]
       }
   }
});
</script>

Mistakes to avoid

gradients: [['#ff9966', '#ff5e62'], ['#00f260', '#0575e6', '#e1eec3']]
Give every gradient in every state the same number of colors

Gradients with different numbers of colors are not supported.

A bare <canvas> with no CSS size, expecting it to cover the section
Stretch the canvas over its box with position absolute, width 100% and height 100%, and put the content above it

The docs' examples size the canvas with CSS; our demo canvases only filled their boxes with these rules.

Leaving several animated canvases running while they are scrolled out of view
Set isPausedWhenNotInView: true, and call destroy() when the block is removed from the page

By default the animation keeps running off screen; it only pauses on a tab change.

image: { blendingMode: 'multiply' } with no source, or an image with no gradients
Pass both image.source and the gradients

The blend only works with an image and gradients set.

License

MIT license. Free to use in personal and paid sites, and you may change and share the code. No visible credit is needed; keep the license notice when you pass the code on.

Commercial use
Yes

“to use, copy, modify, merge, publish, distribute, sublicense, and/or sell” raw.githubusercontent.com

Credit
Not needed

“The above copyright notice and this permission notice shall be included in all” raw.githubusercontent.com

Inside your app or game
Can ship inside your app

“to use, copy, modify, merge, publish, distribute, sublicense, and/or sell” raw.githubusercontent.com

Pass the files on to your users
Allowed

“to use, copy, modify, merge, publish, distribute, sublicense, and/or sell” raw.githubusercontent.com

AI training
Not stated
Bots and bulk downloads
Not stated

AllowedWith conditionsNot allowedNot stated or not checked yet

Is Granim.js free for commercial use? The full answer Not legal advice. Check the license page before you ship.

For your agent

License rules tell your agent what it may do with Granim.js. Paste them into your prompt or AGENTS.md.

License rules
- Granim.js (Video references and motion backgrounds, Backgrounds, patterns and shapes). Tiny library for fluid animated gradient backgrounds on canvas, with gradient states, image blending and transitions. Price: free; commercial use OK; no credit needed. Style: gradient, minimal.
  Connect: npm granim.
  Get files: npm install granim (or CDN), add a <canvas>, new Granim({element, states}) (js, html).
  Rule: Keep the MIT notice if you redistribute the code.
  License: https://raw.githubusercontent.com/sarcadass/granim.js/master/LICENSE (checked 2026-11-05; details: https://agentgid.com/assets/granim-js/)
Can an agent use it by itself?
Yes.

Agent installs a package or loads it from a CDN.

Install
npm install granim
How an agent gets files
npm install granim (or CDN), add a <canvas>, new Granim({element, states}).

Formats: js, html

API, key or account
Not needed. Everything runs on your side.
MCP server
None found
Credit line, if you want one
Animated gradient: Granim.js (MIT License)
This card for machines

Alternatives

Granim.js This page

Free Commercial OK npm

Vanta.js

Pick Vanta.js when you want a moving 3D scene such as waves, fog or birds instead of a flat color gradient.

Free Commercial OK npm

ShaderGradient

Pick ShaderGradient for a soft 3D gradient shaped like waves or a sphere, set up in a visual editor and used from React or Vue.

Free Commercial OK npm

tsParticles

Pick tsParticles when the background should be moving dots, stars, confetti or fireworks rather than colors.

Free Commercial OK npm

three.js examples

Hundreds of official three.js WebGL/WebGPU examples (shaders, particles, post-processing, loaders) with full source in the repo's examples folder.

Free Commercial OK npm

React Three Fiber examples

Gallery of React Three Fiber scenes (shaders, portals, caustics, scroll, physics, glass) linked to runnable sandboxes with source.

Free Commercial OK npm

All video references and motion backgrounds

Questions

Which color formats can I use?

Hex, rgb, rgba, hsl and hsla. You can also set where each color sits in the gradient with a position from 0 to 1.

Which directions are there?

Diagonal (the default), left to right, top to bottom, radial, and a custom direction set in pixels or percentages.

Can I stop or change the animation from my own code?

Yes. The instance has play, pause, clear, changeState, changeDirection, changeBlendingMode and destroy methods.

How fast do the colors change?

By default each change between two gradients takes 5 seconds, and a switch to another state takes 1 second; both are settings in milliseconds.

Can I use it in a paid product?

Yes. The MIT license allows use, change and sale of copies; keep the license notice with the code.