1.0.16 • Published 2 years ago

slim-color-picker v1.0.16

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

a color picker component for Vue3

slim-color-picker

a color picker component for Vue3

Install

npm i slim-color-picker
yarn add slim-color-picker

Usage

<template>

  <SlimColorPicker 
    :width="30"
    :height="30"
    theme="light"
    initFormat="hex"
    okText="ok"
    :radius="4"
    :presets="presets"
    v-model="color"
    @change="onChange" 
  />

</template>

<script lang="ts">

import { defineComponent, ref, reactive } from 'vue';

import SlimColorPicker from 'slim-color-picker'
import 'slim_color_picker/dist/style.css'

export default defineComponent({
  components: { SlimColorPicker },
  setup(props, { attrs, slots, emit, expose }) {

    let color = ref<string>('0066ff)');

    const presets = reactive([
      '#ff4500',
      '#ff8c00',
      '#ffd700',
      '#90ee90',
      '#00ced1',
      '#1e90ff',
      '#c71585',
      'rgba(255, 69, 0, 0.68)',
      'rgb(255, 120, 0)',
      'hsl(181, 100%, 37%)',
      'hsla(209, 100%, 56%, 0.73)'
    ])

    watch(color, (newValue) => {
      console.log('color: ', newValue);
    });

    const onChange = (value) => {
      console.log('value: ', value);
    };

    return {
      color,
      changeColor,
      presets
    };
  },
});
</script>

Property

PropertyRequireTypeDefaultDescription
v-modeltruestring-confirmed color value
widthfalsenumber30trigger handler width
heightfalsenumber39trigger handler height
themefalsestringlightlightdark
initFormatfalsestringhexhexrgbhsl
okTextfalsestringOKconfirm btn text
radiusfalsenumber0trigger handler border-radius
presetsfalsearray[]preset colors for choose

Event

PropertyDescriptionArguments
changecallback when click color panel & barfunction(e)

Thanks

Thank you tinycolor2 for the color format conversion component that makes our development more efficient.

1.0.16

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago