Zurück zum Ranking

linx4200/vue-color

TypeScriptlinx4200.github.io/vue-color/

A modern collection of Vue color pickers – fast, accessible, and easy to use.

color-pickervue-componentsvue-uivue-ui-componentsvue3vue3-typescriptvue
Sterne-Wachstum
Sterne
2.6k
Forks
355
Wochenwachstum
Issues
2
1k2k
Sept. 25Dez. 25Apr. 26Juli 26
Artefaktenpmnpm install vue-color
README

🎨 Vue Color

NPM monthly downloads Github stars

Package Size Test Coverage

A collection of efficient and customizable color pickers, designed for modern web development.

🧪 Live Demo

Explore the components in action: 👉 Open Live Demo

✨ Features

  • Dual Vue Compatibility – Supports both Vue 2.7 and Vue 3 out of the box

  • Modular & Tree-Shakable – Import only what you use

  • TypeScript Ready – Full typings for better DX

  • SSR-Friendly – Compatible with Nuxt and other SSR frameworks

  • Optimized for Accessibility – Built with keyboard navigation and screen readers in mind

  • Dark Mode Support – Built-in dark theme

📦 Installation

npm install vue-color
# or
yarn add vue-color

🚀 Quick Start

1. Import styles

// main.ts
import { createApp } from 'vue'
import App from './App.vue'

// Import styles
import 'vue-color/style.css';

createApp(App).mount('#app')

2. Use a color picker component

<template>
  <ChromePicker v-model="color" />
</template>

<script setup lang="ts">
import { ChromePicker } from 'vue-color'

const color = defineModel({
  default: '#68CCCA'
});
</script>

If you plan to use vue-color with Vue 2.7, please refer to Use with Vue 2.7.

📘 For a full list of available components, see the Documentation.

📚 Documentation

All Available Pickers

All color pickers listed below can be imported as named exports from vue-color.

import { ChromePicker, CompactPicker, HueSlider /** ...etc  */ } from 'vue-color';
Component Name Docs
ChromePicker View
CompactPicker View
GrayscalePicker View
MaterialPicker -
PhotoshopPicker View
SketchPicker View
SliderPicker View
SwatchesPicker View
TwitterPicker View
HueSlider View
AlphaSlider -
HSLSliders View
HSVSliders View
RGBSliders View

Props & Events

All color picker components (expect for <HueSlider />) in vue-color share a set of common props and events for handling color updates and synchronization. Below we'll take <ChromePicker /> as an example to illustrate how to work with v-model.

v-model

<template>
  <ChromePicker v-model="color" />
</template>

<script setup>
import { ChromePicker } from 'vue-color'

const color = defineModel({
  default: 'rgb(50, 168, 82)'
});
</script>

The v-model of vue-color accepts a variety of color formats as input. It will preserve the format you provide, which is especially useful if you need format consistency throughout your app.

const color = defineModel({
  default: 'hsl(136, 54%, 43%)'
  // or
  default: '#32a852'
  // or
  default: '#32a852ff'
  // or
  default: { r: 255, g: 255, b: 255, a: 1 }
});

Under the hood, vue-color uses tinycolor2 to handle color parsing and conversion. This means you can pass in any color format that tinycolor2 supports—and it will just work.

v-model:tinyColor

<template>
  <ChromePicker v-model:tinyColor="tinyColor" />
</template>

<script setup>
import { ChromePicker, tinycolor } from 'vue-color';

const tinyColor = defineModel('tinyColor', {
  default: tinycolor('#F5F7FA')
});
</script>

In addition to plain color values, you can also bind a tinycolor2 instance using v-model:tinyColor. This gives you full control and utility of the tinycolor API.

⚠️ Note: You must use the tinycolor exported from vue-color to ensure compatibility with the library's internal handling.

SSR Compatibility

Since vue-color relies on DOM interaction, components must be rendered client-side. Example for Nuxt:

<template>
  <ClientOnly>
    <ChromePicker />
  </ClientOnly>
</template>

<script setup lang="ts">
import { ClientOnly } from '#components';
import { ChromePicker } from 'vue-color';
</script>

Dark Mode Support

By default, vue-color uses CSS variables defined under the :root scope. To enable dark mode, simply add a .dark class to your HTML element:

<html class="dark">
  <!-- your app -->
</html>

Use with Vue 2.7

To use vue-color with Vue 2.7:

<template>
  <ChromePicker v-model="color" />
</template>

<script setup>
import { ref } from 'vue'
// Note: use the Vue 2.7 specific entry point
import { ChromePicker } from 'vue-color/vue2'

const color = ref('#5c8f94');
</script>

Make sure to use vue-color/vue2 as the import path, and include the correct stylesheet: import vue-color/vue2/style.css in your main entry file.

TypeScript Support in Vue 2.7

Vue 2.7 has full TypeScript support, but vue-color does not include type declarations for the Vue 2.7 build.

You can work around this by manually adding the following shim:

// vue-color-shims.d.ts
declare module 'vue-color/vue2' {
  import { Component } from 'vue';
  import tinycolor from 'tinycolor2';

  export const ChromePicker: Component;
  export const SketchPicker: Component;
  export const PhotoshopPicker: Component;
  export const CompactPicker: Component;
  export const GrayscalePicker: Component;
  export const MaterialPicker: Component;
  export const SliderPicker: Component;
  export const TwitterPicker: Component;
  export const SwatchesPicker: Component;
  export const HueSlider: Component;
  export const tinycolor: typeof tinycolor;
}

declare module '*.css' {
  const content: { [className: string]: string };
  export default content;
}

🧩 FAQ / Issue Guide

Error / Symptom Related Issue
TS2742: The inferred type of 'default' cannot be named without a reference to ... (commonly triggered when using pnpm) #278

🤝 Contributing

Contributions are welcome! Please open issues or pull requests as needed.

📄 License

MIT

Ähnliche Repositories
microsoft/PowerToys

Microsoft PowerToys is a collection of utilities that supercharge productivity and customization on Windows

CMIT Licensepowertoysdesktop
136.6k8.3k
ShareX/ShareX

ShareX is a free and open-source application that enables users to capture or record any area of their screen with a single keystroke. It also supports uploading images, text, and various file types to a wide range of destinations.

C#GNU General Public License v3.0screen-capturescreen-recorder
getsharex.com
38.7k3.9k
casesandberg/react-color

:art: Color Pickers from Sketch, Photoshop, Chrome, Github, Twitter & more

JavaScriptnpmMIT Licensereactreact-component
casesandberg.github.io/react-color/
12.3k922
HandyOrg/HandyControl

Contains some simple and commonly used WPF controls

C#MIT Licensewpfwpf-ui
handyorg.github.io
7.1k1.2k
xushengfeng/eSearch

截屏 离线OCR 搜索翻译 以图搜图 贴图 录屏 万向滚动截屏 屏幕翻译 Screenshot Offline OCR Search Translate Search for picture Paste the picture on the screen Screen recorder Omnidirectional scrolling screenshot Screen translator 支持Windows Linux macOS

TypeScriptnpmGNU General Public License v3.0screenshotscreen-capture
esearch-app.netlify.app
6.6k490
dillidon/alerts-and-pickers

Advanced usage of UIAlertController and pickers based on it: Telegram, Contacts, Location, PhotoLibrary, Country, Phone Code, Currency, Date...

SwiftMIT Licenseuialertcontrollerpicker
5.8k702
simonwep/pickr

🎨 Pickr - A simple, multi-themed, responsive and hackable Color-Picker library. No dependencies, no jQuery. Compatible with all CSS Frameworks e.g. Bootstrap, Materialize. Supports alpha channel, rgba, hsla, hsva and more!

JavaScriptnpmMIT Licensecolor-pickercolorpicker
simonwep.github.io/pickr
4.5k291
omgovich/react-colorful

🎨 A tiny (2,8 KB) color picker component for React and Preact apps

TypeScriptnpmMIT Licensecolor-pickercolor
omgovich.github.io/react-colorful
3.5k121
adobe/leonardo

Generate colors based on a desired contrast ratio

JavaScriptnpmApache License 2.0contrast-ratioa11y
leonardocolor.io
2.1k129
Toinane/colorpicker

Your powerful toolkit for mastering colors.

JavaScriptnpmGNU General Public License v3.0color-pickercomparison
colorpicker.fr
1.9k137
skydoves/ColorPickerView

🎨 Android colorpicker for getting colors from any images by tapping on the desired color.

JavaMavenApache License 2.0android-librarycolorpicker
skydoves.github.io/ColorPickerView/
1.7k228
jaames/iro.js

🎨 Modular color picker widget for JavaScript, with support for a bunch of color formats

JavaScriptnpmMozilla Public License 2.0color-pickerjavascript
iro.js.org
1.5k93