Vue 3 port of react-colorful, maintained by RareFormLabs.
It keeps the original library's strengths:
- tiny, dependency-free pickers
- keyboard and touch support
- multiple color models
- Shadow DOM-aware style injection
- CSP nonce support via
setNonce()
- GitHub Pages: https://rareformlabs.github.io/vue-colorful/
- Upstream project: https://github.com/omgovich/react-colorful
npm install @rareformlabs/vue-colorful<script setup lang="ts">
import { ref } from "vue";
import { HexColorPicker } from "@rareformlabs/vue-colorful";
const color = ref("#aabbcc");
</script>
<template>
<HexColorPicker v-model:color="color" />
</template>Every picker supports:
v-model:colorfor two-way binding@changefor every intermediate update while dragging or using the keyboard@change-endfor the committed value after mouseup, touchend, or keyup
<HexColorPicker
v-model:color="color"
@change="previewColor"
@change-end="saveColor"
/>import {
HexColorPicker,
HexAlphaColorPicker,
RgbColorPicker,
RgbaColorPicker,
RgbStringColorPicker,
RgbaStringColorPicker,
HslColorPicker,
HslaColorPicker,
HslStringColorPicker,
HslaStringColorPicker,
HsvColorPicker,
HsvaColorPicker,
HsvStringColorPicker,
HsvaStringColorPicker,
HexColorInput,
} from "@rareformlabs/vue-colorful";<script setup lang="ts">
import { ref } from "vue";
import { HexColorInput, HexColorPicker } from "@rareformlabs/vue-colorful";
const color = ref("#7f5af0");
</script>
<template>
<HexColorPicker v-model:color="color" />
<HexColorInput v-model:color="color" prefixed />
</template>HexColorInput props:
prefixedadds the leading#alphaenables#rgbaand#rrggbbaa
If your app needs a nonce for inline styles, set it before mounting a picker:
import { setNonce } from "@rareformlabs/vue-colorful";
setNonce("your-csp-nonce");npm install
npm run dev
npm run build
npm run typecheck
npm test- The repository is named
vue-colorful, while preserving the original lineage fromreact-colorful. - The default demo deploys through GitHub Actions to GitHub Pages.