Skip to main content

Color Input

This is a Labs component. The API may change in future releases. Import from vuetify/labs/VColorInput.
The VColorInput component provides a text field with an integrated color picker, allowing users to type color values or use a visual picker.

Usage

<template>
  <v-color-input
    v-model="color"
    label="Select Color"
  />
</template>

<script setup>
import { ref } from 'vue'
import { VColorInput } from 'vuetify/labs/VColorInput'

const color = ref('#FF5252')
</script>

API

Props

Inherits all VTextField and VColorPicker props, plus:
modelValue
string
The selected color value.
hidePip
boolean
default:"false"
Hides the color indicator pip.
colorPip
boolean
default:"false"
Colors the pip with the selected color.
pipIcon
string
default:"$color"
Icon displayed in the color pip.
pipLocation
string
default:"prepend"
Location of the color pip. Options: prepend, prepend-inner, append, append-inner.
pipVariant
string
default:"text"
Variant style for the pip avatar.
menuProps
object
Props passed to the internal VMenu component.
pickerProps
object
Props passed to the internal VColorPicker component.
hideActions
boolean
default:"false"
Hides the save/cancel action buttons.

Events

update:modelValue
(value: string) => void
Emitted when the color value changes.

Slots

Inherits all VTextField slots, plus:
actions
{ save, cancel, isPristine }
Customize the action buttons in the color picker.

Examples

With Color Pip

<template>
  <v-color-input
    v-model="color"
    label="Background Color"
    color-pip
  />
</template>

<script setup>
import { ref } from 'vue'
import { VColorInput } from 'vuetify/labs/VColorInput'

const color = ref('#1976D2')
</script>

Custom Picker Props

<template>
  <v-color-input
    v-model="color"
    label="Color"
    :picker-props="{
      showSwatches: true,
      mode: 'hex'
    }"
  />
</template>

Without Actions

<template>
  <v-color-input
    v-model="color"
    label="Quick Color"
    hide-actions
  />
</template>

Different Pip Locations

<template>
  <div class="d-flex flex-column ga-4">
    <v-color-input
      v-model="color1"
      label="Prepend"
      pip-location="prepend"
      color-pip
    />
    <v-color-input
      v-model="color2"
      label="Prepend Inner"
      pip-location="prepend-inner"
      color-pip
    />
    <v-color-input
      v-model="color3"
      label="Append"
      pip-location="append"
      color-pip
    />
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { VColorInput } from 'vuetify/labs/VColorInput'

const color1 = ref('#FF5252')
const color2 = ref('#4CAF50')
const color3 = ref('#2196F3')
</script>

Custom Actions

<template>
  <v-color-input v-model="color" label="Color">
    <template #actions="{ save, cancel }">
      <v-btn @click="cancel" text="Cancel" />
      <v-btn @click="save" color="primary" text="Apply" />
    </template>
  </v-color-input>
</template>

With Validation

<template>
  <v-color-input
    v-model="color"
    label="Theme Color"
    :rules="[rules.required, rules.hex]"
  />
</template>

<script setup>
import { ref } from 'vue'
import { VColorInput } from 'vuetify/labs/VColorInput'

const color = ref('')

const rules = {
  required: value => !!value || 'Color is required',
  hex: value => /^#[0-9A-F]{6}$/i.test(value) || 'Invalid hex color'
}
</script>

Disabled and Readonly

<template>
  <div class="d-flex flex-column ga-4">
    <v-color-input
      v-model="color"
      label="Disabled"
      disabled
    />
    <v-color-input
      v-model="color"
      label="Readonly"
      readonly
    />
  </div>
</template>

Build docs developers (and LLMs) love