Getting started

Getting started

Install the package, build a gradient string, and set it wherever CSS takes a gradient.

Install

npm install @reuse-sh/gradients

Build a gradient

easingGradient returns a CSS string. Set it as a background or a mask, in a style attribute, CSS-in-JS or a server template. There is nothing to destroy.

import { easingGradient } from "@reuse-sh/gradients";

// A scrim that eases from nothing to 72% black, for text over an image.
scrim.style.backgroundImage = easingGradient({
  to: "rgb(0 0 0 / 0.72)",
  direction: "to bottom",
});

Fade a scrolling edge

createFadeEdge masks the sides of a horizontal scroller with the same eased stops. Destroy it with the scroller, and it puts the old inline style back.

import { createFadeEdge } from "@reuse-sh/gradients";

const strip = document.querySelector(".prints");
const fade = createFadeEdge(strip, { size: 64, curve: "smooth", mode: "scroll" });

// Change it later, or remove it with the strip.
fade.update({ mode: "fixed" });
fade.destroy();

Hand this page to your coding agent.

Read https://reuse.sh/easing-gradients/guide.md, install @reuse-sh/gradients and add Easing gradients to <where>. Keep the principles the guide lists.