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-picker-gradient

v2.0.0

Published

vue3,颜色选择器,线性(纯色)、渐变选择器,支持角度、多点渐变

Readme

vue3-color-picker-gradient

npm npm GitHub stars

🎨 Color Picker with Gradient support for Vue 3, inspired by Element-Plus design.

Supports both solid colors and gradient colors with an intuitive trigger button and popup panel.

1657866184714

✨ Features

  • 🎯 Element-Plus Style API - Similar to el-color-picker usage
  • 🌈 Dual Mode - Solid color (linear) and Gradient color (gradient)
  • 📦 v-model Support - Direct color value binding
  • 🎪 Popper Dropdown - Auto-positioning popup panel
  • 🚫 Disabled State - Support for disabled mode
  • 🎨 Gradient Controls - Angle adjustment and multi-point gradients
  • 🎭 Click Outside to Close - Auto-close when clicking outside
  • 📱 Responsive - Smart positioning on scroll and resize

Live demo

Installation

NPM

$ npm install vue3-color-picker-gradient

ES6

Global Registration

import { createApp } from 'vue'
import ColorPickerGradient from 'vue3-color-picker-gradient'

const app = createApp(App)
app.use(ColorPickerGradient)

Local Registration

import ColorPickerGradient from 'vue3-color-picker-gradient'

export default {
  name: 'App',
  components: {
    ColorPickerGradient,
  },
}

📚 API

Props

| Property | Type | Default | Description | |----------|------|---------|-------------| | modelValue / v-model | String | '' | Binding value (rgba string for solid color, linear-gradient string for gradient) | | type | String | 'linear' | Picker type: 'linear' (solid) or 'gradient' (gradient) | | disabled | Boolean | false | Whether to disable the picker | | showAlpha | Boolean | true | Whether to display alpha slider | | disabledColorDeg | Boolean | false | Whether to disable angle control (gradient mode only) | | colorFormat | String | 'rgba' | Color format | | size | String | 'default' | Picker size: 'large' / 'default' / 'small' | | titleConfig | Object | {text:'颜色选择器',show:true} | Title configuration |

Events

| Event Name | Parameters | Description | |------------|------------|-------------| | change | (value: string) | Triggered when the color value changes | | active-change | (value: string) | Triggered when the active color changes |

📖 Usage Examples

Basic Usage - Solid Color

<template>
  <ColorPickerGradient
    v-model="color"
    type="linear"
    @change="handleColorChange"
  />
</template>

<script>
import { ref } from 'vue'
import ColorPickerGradient from 'vue3-color-picker-gradient'

export default {
  components: { ColorPickerGradient },
  setup() {
    const color = ref('rgba(255, 0, 0, 1)')

    const handleColorChange = (value) => {
      console.log('Color changed:', value)
    }

    return { color, handleColorChange }
  }
}
</script>

Gradient Color

<template>
  <ColorPickerGradient
    v-model="gradient"
    type="gradient"
  />
</template>

<script>
import { ref } from 'vue'
import ColorPickerGradient from 'vue3-color-picker-gradient'

export default {
  components: { ColorPickerGradient },
  setup() {
    const gradient = ref('linear-gradient(90deg, rgba(255,0,0,1) 0%, rgba(0,0,255,1) 100%)')

    return { gradient }
  }
}
</script>

Disabled State

<template>
  <ColorPickerGradient
    v-model="color"
    :disabled="true"
  />
</template>

Disable Angle Control (Gradient Mode)

<template>
  <ColorPickerGradient
    v-model="gradient"
    type="gradient"
    :disabledColorDeg="true"
  />
</template>

Complete Example

<template>
  <div class="demo">
    <h2>Solid Color Picker</h2>
    <ColorPickerGradient
      v-model="solidColor"
      type="linear"
      @change="handleChange"
    />
    <div class="preview" :style="{ background: solidColor }">
      {{ solidColor }}
    </div>

    <h2>Gradient Color Picker</h2>
    <ColorPickerGradient
      v-model="gradientColor"
      type="gradient"
      @change="handleGradientChange"
    />
    <div class="preview" :style="{ background: gradientColor }">
      {{ gradientColor }}
    </div>
  </div>
</template>

<script>
import { ref } from 'vue'
import ColorPickerGradient from 'vue3-color-picker-gradient'

export default {
  components: { ColorPickerGradient },
  setup() {
    const solidColor = ref('rgba(64, 158, 255, 1)')
    const gradientColor = ref('linear-gradient(90deg, rgba(255,255,255,1) 0%, rgba(0,0,0,1) 100%)')

    const handleChange = (value) => {
      console.log('Solid color:', value)
    }

    const handleGradientChange = (value) => {
      console.log('Gradient color:', value)
    }

    return {
      solidColor,
      gradientColor,
      handleChange,
      handleGradientChange
    }
  }
}
</script>

<style scoped>
.demo {
  padding: 20px;
}

.preview {
  width: 200px;
  height: 100px;
  margin-top: 10px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 12px;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}
</style>

🔧 Development

Install Dependencies

npm install

Compiles and hot-reloads for development

npm run serve

Compiles and minifies for library

npm run lib

Lints and fixes files

npm run lint

🔄 Migration from Old API

If you're upgrading from the old API, here's a comparison:

Old API (v-model controls visibility):

<ColorPicker
  v-model="isShowColorPicker"
  type="linear"
  @changeColor="changeColor"
  :pColor="pColor"
/>

New API (v-model binds color value):

<ColorPickerGradient
  v-model="color"
  type="linear"
  @change="handleChange"
/>

Key Changes:

  • v-model now binds the color value directly (not visibility)
  • ✅ Automatic trigger button with popup panel
  • ✅ Simplified event: @change instead of @changeColor
  • ✅ Simplified props: direct color string instead of complex objects
  • ✅ Auto-close on outside click (no need for closeOnClickBody)

🤝 Contributing

Contributions are welcome! Feel free to submit issues and pull requests.

📄 License

MIT

⭐ Show Your Support

If this project helped you, please give it a ⭐️!

欢迎点个 star 🎉🎉🎉


Customize configuration

See Configuration Reference.