Skip to content

Guides

Overview

  • Supports 3 CSS background color modes: solid, linear-gradient and radial-gradient.
  • Supports color opacity(alpha) adjustment.
  • Supports gradient bar control, easily drag/add/delete the control points.
  • The EyeDropper can quickly pick any color from your screen. (supports Google Chrome version 95+)
  • Supports live preview.

screenshot01screenshot02screenshot03

Installation

bash
npm i @mcistudio/vue-colorpicker

How to Use

  • Global Registration
javascript
import ColorPicker from '@mcistudio/vue-colorpicker'
import '@mcistudio/vue-colorpicker/style.css'
createApp(App)
  .use(ColorPicker)
  .mount("#app");
  • Local Registration
vue
<script setup>
import ColorPicker from '@mcistudio/vue-colorpicker'
import '@mcistudio/vue-colorpicker/dist/style.css'

<template>
  <ColorPicker></ColorPicker>
</template>
</script>

Props

Prop NameDescriptionTypeAccepted ValueDefault ValueRequired
v-modelbinding valueJSON<v-model>No
modebarshow mode barStringshow
none
showNo
sizebutton sizeStringsmall
medium
large
mediumNo

v-model

DescriptionTypeAccepted ValueDefault ValueRequired
modecolor modeStringsolid
linear
radial
solidNo
colorrgba color value in solid modeString-{ r: 0, g: 0, b: 0, a: 1 }No
hexHex color value in solid mode (Read Only)String--No
degreedrgee value in Linear-gradient modeNumber-90No
gradientsgradient list
JSON Array-[
{
percent: 0,
color: { r: 255, g: 255, b: 255, a: 1 }
}
{
percent: 100,
color: { r: 0, g: 0, b: 0, a: 1 }
}
]```
No

Events

event NameDescriptionParameters
colorChangedTriggered when color changesreturnValue
returnValue examples:

Solid Mode

json
{
    "mode": "solid",
    "color": {
        "r": 0,
        "g": 0,
        "b": 0,
        "a": 1
    },
  	"hex":'#000000',
    "css": "background-color:rgba(0,0,0,1)"
}

Linear Mode

json
{
    "mode": "linear",
    "degree": 90,
    "color": [
        {
            "percent": 0,
            "color": {
                "r": 255,
                "g": 255,
                "b": 255,
                "a": 1
            }
        },
        {
            "percent": 100,
            "color": {
                "r": 0,
                "g": 0,
                "b": 0,
                "a": 1
            }
        }
    ],
    "css": "background-image:linear-gradient(90deg,rgba(255,255,255,1) 0%,rgba(0,0,0,1) 100%)"
}

Radial Mode

json
{
    "mode": "radial",
    "color": [
        {
            "percent": 0,
            "color": {
                "r": 255,
                "g": 255,
                "b": 255,
                "a": 1
            }
        },
        {
            "percent": 100,
            "color": {
                "r": 0,
                "g": 0,
                "b": 0,
                "a": 1
            }
        }
    ],
    "css": "background-image:radial-gradient(rgba(255,255,255,1) 0%,rgba(0,0,0,1) 100%)"
}

Released under the MIT License.