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

vue3-color-gradient-picker

v1.0.3

Published

Color and gradient picker for vue3.js

Readme

vue3-color-gradient-picker

npm downloads license

A color and gradient picker component for Vue 3.

vue3-color-gradient-picker

Features

  • Solid color picking with saturation / value area, hue slider and alpha slider
  • Linear and radial gradients with any number of color stops
  • Adjustable gradient angle by dragging the dial or clicking it to rotate 45°
  • HEX (including 8-digit #RRGGBBAA) and RGBA inputs
  • Start / change / end callbacks with a ready-to-use CSS value

Installation

npm install vue3-color-gradient-picker
# or
yarn add vue3-color-gradient-picker
# or
pnpm add vue3-color-gradient-picker

Requires Vue 3.3 or later.

Usage

Import the component and its stylesheet:

import { ColorPicker } from 'vue3-color-gradient-picker';
import 'vue3-color-gradient-picker/dist/style.css';

Solid color

<script setup>
import { ref } from 'vue';
import { ColorPicker } from 'vue3-color-gradient-picker';
import 'vue3-color-gradient-picker/dist/style.css';

const color = ref({ red: 255, green: 0, blue: 0, alpha: 1 });

function onChange(value) {
  color.value = { ...value };
  console.log(value.style); // rgba(255, 0, 0, 1)
}
</script>

<template>
  <ColorPicker :color="color" :onChange="onChange" />
</template>

Gradient

<script setup>
import { ColorPicker } from 'vue3-color-gradient-picker';
import 'vue3-color-gradient-picker/dist/style.css';

const gradient = {
  type: 'linear',
  degree: 90,
  points: [
    { left: 0, red: 0, green: 0, blue: 0, alpha: 1 },
    { left: 100, red: 255, green: 0, blue: 0, alpha: 1 },
  ],
};

function onChange(value) {
  console.log(value.style); // linear-gradient(90deg,rgba(0, 0, 0, 1) 0%,rgba(255, 0, 0, 1) 100%)
}
</script>

<template>
  <ColorPicker is-gradient :gradient="gradient" :onChange="onChange" />
</template>

Gradient interactions:

| Action | Result | | --- | --- | | Click the gradient bar | Add a color stop at that position | | Drag a color stop | Move the stop | | Double-click a stop, or press Delete / Backspace | Remove the active stop (at least two stops are kept) | | Click the angle dial | Rotate the linear gradient by 45° | | Drag the angle dial | Set the angle freely |

Props

| Prop | Type | Default | Description | | --- | --- | --- | --- | | isGradient | Boolean | false | Show the gradient picker instead of the solid color picker | | color | Object | { red: 255, green: 0, blue: 0, alpha: 1 } | Solid color. red / green / blue range from 0 to 255, alpha from 0 to 1. Optional hue, saturation and value can be passed to keep the HSV position exact | | gradient | Object | Black to red, linear, 0° | Initial gradient, see the structure below. It is read when the component is mounted | | onStartChange | Function | — | Called when a drag starts | | onChange | Function | — | Called on every change | | onEndChange | Function | — | Called when a drag ends |

Gradient structure:

{
  type: 'linear', // 'linear' | 'radial'
  degree: 90,     // angle of the linear gradient, 0 - 360
  points: [
    // left: position of the stop in percent, 0 - 100
    { left: 0, red: 0, green: 0, blue: 0, alpha: 1 },
    { left: 100, red: 255, green: 0, blue: 0, alpha: 1 },
  ],
}

Callback value

Solid mode:

{ red, green, blue, alpha, hue, saturation, value, style } // style: 'rgba(r, g, b, a)'

Gradient mode:

{ points, type, degree, style } // style: a CSS linear-gradient() / radial-gradient() value

Adding or removing a stop and changing the gradient type or angle only trigger onChange. To persist the gradient, listen to onChange.

Styles

The stylesheet must be imported manually from vue3-color-gradient-picker/dist/style.css. Note that it applies box-sizing: border-box to all elements on the page.

Development

npm install
npm run dev    # start the demo with hot reload
npm run build  # build the library into dist/
npm run lint

Changelog

1.0.3

  • Fixed pointer offsets when the page is scrolled
  • Fixed the picker not working when mounted inside a hidden container, such as a popover or dialog
  • Fixed a small offset when clicking the hue and alpha sliders
  • Fixed the angle dial calculating a wrong angle
  • Fixed Delete / Backspace removing gradient stops while typing in an input
  • Fixed the keyboard listener not being removed when the component is unmounted
  • Fixed the active color not updating after a gradient stop is removed
  • Fixed 8-digit HEX input setting alpha to 0
  • Limited the alpha input to 0 - 100
  • Removed the invalid browser field from package.json

License

MIT © Bamzc