vue-color icon indicating copy to clipboard operation
vue-color copied to clipboard

Possibility to put HEX in and get only the HEX out (no other color formats)

Open range-of-motion opened this issue 5 years ago • 7 comments

As the title says. When I say myHex: '#FF0000', and use that as the v-model, I expect the updated myHex variable to be a HEX code, not an object containing a HEX code (and other color formats).

Is this possible?

range-of-motion avatar Sep 11 '19 17:09 range-of-motion

If i undersand your question, then you can do this:

<chrome-picker @input="input" v-model="colors" />

and listen to it and get the value from it:

  methods: {
    input(color) {
      console.log(color.hex);
    }
  }

Pixney-William avatar Oct 02 '19 20:10 Pixney-William

but if you have multiple color pickers on one page, that's not going to help, because every picker would need his own input method

sebbmeyer avatar Oct 29 '19 17:10 sebbmeyer

Uniforming input and output format seems like a common request. Gonna think about it. But this is a breaking change, so if it takes not much efforts, will implement in 3.0 version.

linx4200 avatar Feb 27 '20 00:02 linx4200

Yes please 😩

range-of-motion avatar Feb 27 '20 00:02 range-of-motion

Consider vue-select`s example in this case, they use reduce callback to pass only needed data to v-model https://vue-select.org/guide/values.html#returning-a-single-key-with-reduce

downtest avatar Aug 06 '20 10:08 downtest

I was troubled with the same problem. As a result of trial and error, I wrote temporarily as follows.

data() {
  return {
    myHex: "#C6E1B880",
  }
}
<chrome-picker :value="myHex" @input="c => myHex = c.hex8" />

It is a pity that v-model can not be used very effectively

akicho8 avatar Dec 05 '20 03:12 akicho8

You can also write <chrome-picker :value="myHex" @input="myHex = $event.hex8" />

Tofandel avatar Aug 04 '21 18:08 Tofandel