npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

gradient-border-react

v0.2.0

Published

Animated gradient border that flows around any element. A tiny, dependency-free React component for React 18 and 19.

Readme

gradient-border-react

tests coverage license npm version npm downloads bundle size

🌐 Live demo →

An animated gradient border that flows around any element. Tiny, dependency-free, and it respects prefers-reduced-motion out of the box. Works with React 18 and React 19.

<GradientBorder colors={['#7C3AED', '#06B6D4', '#10B981']} radius={16} glow>
  <div style={{ padding: 24 }}>Wrap me ✨</div>
</GradientBorder>

No CSS file to import, no canvas, no requestAnimationFrame — just a masked, rotating conic-gradient driven by a registered @property. One <style> of keyframes is injected once, and that's the whole runtime.

Install

From GitHub (always works):

pnpm add github:kea0811/gradient-border-react

From npm (when published to npm):

pnpm add gradient-border-react

Prefer npm or yarn? npm install gradient-border-react / yarn add gradient-border-react work too.

react and react-dom are peer dependencies (^18 || ^19).

Quick start

import { GradientBorder, presets } from 'gradient-border-react';

export function ProfileCard() {
  return (
    <GradientBorder colors={presets.aurora} radius={16} borderWidth={2} background="#0d0d16">
      <div style={{ padding: 24 }}>
        <h3>Ada Lovelace</h3>
        <p>The first programmer.</p>
      </div>
    </GradientBorder>
  );
}

That's it — the border animates immediately. Wrap a card, a button, an avatar, an input; the gradient keeps flowing around whatever's inside.

Features

  • 🎈 Tiny & dependency-free — a couple of inline styles and one injected keyframe block.
  • 🌈 Eight presets plus any custom color array you like.
  • ♿️ Reduced-motion aware — the ring freezes to a static gradient when the user asks for less motion, and the decorative layers are hidden from assistive tech.
  • 🧩 Composable — use the <GradientBorder> component, or the useGradientBorder() hook to paint the look onto your own markup.
  • ⚛️ React 18 & 19 — StrictMode-safe; all lifecycle lives in a single effect.
  • 🧪 100% test coverage, TypeScript strict mode, ESM + CJS + types.

API

<GradientBorder>

A <div> wrapper around your content. Accepts every standard div prop (className, style, onClick, aria-*, a forwarded ref, …) plus:

| Prop | Type | Default | Description | | ------------- | -------------------- | -------------- | ------------------------------------------------------------------------ | | colors | string[] | presets.aurora | Colors the gradient cycles through. Treated as a loop; a single color is allowed. | | borderWidth | number | 2 | Border thickness, in pixels. | | radius | number | 12 | Corner radius, in pixels. | | duration | number | 4 | Seconds for one full rotation. Lower is faster. | | direction | 'cw' \| 'ccw' | 'cw' | Spin direction. | | paused | boolean | false | Freeze the animation on its current frame. | | background | string | 'transparent'| Fill painted inside the border (turn the frame into a card). | | glow | boolean | false | Add a soft, blurred glow of the same gradient behind the box. |

useGradientBorder(options?)

The component is a thin wrapper around this hook. It returns the inline styles for each layer, so you can compose the border onto any element you control:

import { useGradientBorder, presets } from 'gradient-border-react';

function FancyButton() {
  const { ring, content } = useGradientBorder({ colors: presets.candy, radius: 999 });
  return (
    <div style={ring}>
      <button style={content}>Click me</button>
    </div>
  );
}

It returns { outer, glow, ring, content } — all React.CSSProperties. options takes the same fields as the component props above.

presets / presetNames

import { presets, presetNames } from 'gradient-border-react';

presets.sunset; // ['#F59E0B', '#EF4444', '#EC4899', '#8B5CF6']
presetNames;    // ['aurora', 'sunset', 'ocean', 'candy', 'ember', 'mint', 'mono', 'rainbow']

usePrefersReducedMotion()

The same accessibility hook the border uses internally, exported for convenience. Returns a boolean that updates live when the user's setting changes.

Accessibility

GradientBorder reads prefers-reduced-motion and renders a static gradient when reduced motion is requested — no flag needed. The glow and ring layers are purely decorative and marked aria-hidden, so screen readers only ever see your content.

Browser support

The effect relies on CSS @property to smoothly interpolate the gradient angle (Chrome/Edge 85+, Safari 16.4+, Firefox 128+). In older engines the gradient still renders — it just won't rotate, which is a perfectly fine fallback.

Live demo

See every prop in action: gradient-border-react.vercel.app

To run it locally:

pnpm install
pnpm build        # build the library once
pnpm demo:dev     # start the demo at http://localhost:5173

Contributing

Issues and PRs are welcome. To hack on it:

pnpm install
pnpm test          # run the suite
pnpm test:coverage # 100% across the board
pnpm build         # ESM + CJS + .d.ts

License

MIT © kea0811