Skip to content

ColorPicker API Reference

Props

PropTypeDefaultDescription
valueString"#FFFFFF"The selected color value in hex format
placeholderString"Select color"Placeholder text when no color is selected
disabledBooleanfalseWhether the color picker is disabled
hideInputsBooleanfalseWhether to hide the color input fields
hideCanvasBooleanfalseWhether to hide the color canvas
hideSlidersBooleanfalseWhether to hide the color sliders
showSwatchesBooleantrueWhether to show color swatches
swatchesArray[]Custom color swatches to display
elevationNumber1Elevation level for the color picker dropdown (0-24)
scaleNumber1Scale factor for the color picker dropdown
emitColorOnCloseDropdownBooleanfalseWhether to emit color only when dropdown closes
bgColorString'white'Background color for the color picker
widthNumber/String200Width of the color picker dropdown
swatchesMaxHeightNumber/String100Maximum height of the swatches section

Events

EventPayloadDescription
onSelectColorStringEmitted when the selected color changes, with the new color value in hex format

Slots

SlotPropsDescription
formattedColor-Custom formatting for the selected color display

Methods

The component doesn't expose any methods via template refs.

Example Usage

vue
<template>
  <OColorPicker
    :value="selectedColor"
    placeholder="Select color"
    :showSwatches="true"
    @onSelectColor="handleColorChange"
  >
    <template #formattedColor>
      <div class="custom-color-display">
        <div class="color-box" :style="{ backgroundColor: selectedColor }"></div>
        <span>{{ selectedColor || 'No color selected' }}</span>
      </div>
    </template>
  </OColorPicker>
</template>

<script setup>
import { ref } from 'vue'
import { OColorPicker } from 'your-component-library'

const selectedColor = ref('#4a90e2')

const handleColorChange = (color) => {
  selectedColor.value = color
}
</script>

<style scoped>
.custom-color-display {
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-box {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid #ddd;
}
</style>

Dependencies

This component requires the v-color-picker component from Vuetify to be available, which should be imported and registered in your application.