Skip to content

advplyr/vue-tailwind-color-picker

Repository files navigation

Vue Tailwind Color Picker

Color picker for vue using Tailwind v2.

Requires Tailwind

Installation

$ npm install vue-tailwind-color-picker
$ yarn add vue-tailwind-color-picker

Installation Nuxt

Global add plugins

plugins/vue-tailwind-color-picker.js

import Vue from 'vue'
import VueTailwindColorPicker from 'vue-tailwind-color-picker'
Vue.use(VueTailwindColorPicker)

add nuxt.config.js

plugins: [
    '~/plugins/vue-tailwind-color-picker',
  ],

Installation Nuxt Typescript

Global add plugins

plugins/vue-tailwind-color-picker.ts

import Vue from 'vue'
// @ts-ignore
import VueTailwindColorPicker from 'vue-tailwind-color-picker'
Vue.use(VueTailwindColorPicker)

add nuxt.config.ts

plugins: [
    '~/plugins/vue-tailwind-color-picker',
  ],

Usage

<template>
   <vue-tailwind-color-picker v-model="color" :swatches.sync="swatches" :hide-swatches="false" @change="changedColor" @addSwatch="swatchAdded" @deleteSwatch="swatchDeleted" />
</template>

<script>
import VueTailwindColorPicker from 'vue-tailwind-color-picker.vue'

export default {
  components: {
    VueTailwindColorPicker
  },
  data() {
    return {
      color: '#00FF00FF',
      swatches: [
        '#f94144',
        '#f3722c',
        '#f8961e',
        '#f9c74f',
        '#90be6d',
        '#43aa8b',
        '#577590',
        '#22223b',
        '#4a4e69',
        '#c9ada7'
      ]
    }
  },
  methods: {
    changedColor(color) {
      console.warn('Changed Color', color)
    },
    swatchAdded(color) {
      console.log('Swatch Added', color)
    },
    swatchDeleted(color) {
      console.log('Swatch Deleted', color)
    }
  }
}
</script>

License

MIT

About

Vue Color Picker using Tailwind@2

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published