Skip to content

SColorPicker <s-color-picker> ​

ts
import { SColorPicker } from 'polaris-vue-elements'

Example ​

Value: #008060

vue
<script setup>
import { ref } from 'vue'
import { SColorPicker } from 'polaris-vue-elements'

const value = ref('#008060')
</script>

<template>
  <SColorPicker v-model="value" />
  <p>Value: {{ value }}</p>
</template>

v-model ​

v-model on <SColorPicker> binds to the value property and listens for the input DOM event.

template
<SColorPicker v-model="value" />

is equivalent to:

template
<SColorPicker :value="value" @input="value = $event.target.value" />

Props ​

PropTypeDescription
alphabooleanWhether to enable alpha (transparency) channel selection in the color picker, allowing users to choose semi-transparent colors.
defaultValuestringThe initial color value when the field first loads. Unlike placeholder, this is a real value that the user can edit and that gets submitted with the form. Once the user starts interacting, their input replaces it. Changing this property after the field has loaded has no effect. To update the field value at any time, use value instead.
idstringA unique identifier for the element.
namestringAn identifier for the field that is unique within the nearest containing form.
valuestringThe currently selected color value. Accepts multiple input formats: - Hex: #RGB, #RRGGBB, #RRGGBBAA (3, 6, or 8 digits) - RGB/RGBA: rgb(255, 0, 0) or rgb(255 0 0) (comma or space-separated) - HSL/HSLA: hsl(0, 100%, 50%) or hsl(0 100% 50%) Returns an empty string if the value is invalid. The change event always emits values in hex format.

Events ​

EventType
changeCustomEvent
inputCustomEvent

Listen for these with @change-style listeners on <SColorPicker>.

Released under the MIT License.