QColorpicker 🎨

Being used to pick color value.

When to use

  • When you need to pick a color as value.

Example

Default view:

Using in template:

<q-color-picker v-model="color" />
1

Using in component instance:

  setup() {
    const color = ref('#f25');

    return { color };
  }
1
2
3
4
5

Props

modelValue

  • Type: String
  • Default: null

Binding value.

// import type from lib
import type { QDatePickerPropModelValue } from '@qvant/qui-max';

// TS type
type QDatePickerPropModelValue = Nullable<string | Date | string[] | Date[]>;
1
2
3
4
5

popperOptions

  • Type: Object
  • Default: null

We use Popper.js to show tooltips & popovers. See full options guide hereopen in new window

export type QColorPickerPropPopperOptions = Nullable<Partial<Options>>;

export declare type Options = {
  placement: Placement;
  modifiers: Array<Partial<Modifier<any, any>>>;
  strategy: PositioningStrategy;
  onFirstUpdate?: (arg0: Partial<State>) => void;
};
1
2
3
4
5
6
7
8

disabled

  • Type: Boolean
  • Default: false

Whether to disable the ColorPicker.

<q-color-picker
  v-model="color"
  disabled
/>


 

1
2
3
4

clearable

  • Type: Boolean
  • Default: true

Whether to show clear button.

<q-color-picker
  v-model="color"
  clearable
/>


 

1
2
3
4

alphaShown

  • Type: Boolean
  • Default: false

Whether to display the alpha slider.

<q-color-picker
  v-model="color"
  alpha-shown
/>


 

1
2
3
4

colorFormat

  • Type: 'hex' | 'rgb'
  • Default: 'hex'

Output color format.

<q-color-picker
  v-model="color"
  color-format="rgb"
/>


 

1
2
3
4

placement

  • Type: String
  • Default: 'right-start'

Sets picker placement around the button.

<q-color-picker
  v-model="color"
  placement="bottom"
/>


 

1
2
3
4
// ts type
type Placement = AutoPlacement | BasePlacement | VariationPlacement;
type AutoPlacement = 'auto' | 'auto-start' | 'auto-end';
type BasePlacement = 'top' | 'bottom' | 'right' | 'left';
type VariationPlacement =
  | 'top-start'
  | 'top-end'
  | 'bottom-start'
  | 'bottom-end'
  | 'right-start'
  | 'right-end'
  | 'left-start'
  | 'left-end';
1
2
3
4
5
6
7
8
9
10
11
12
13

teleportTo

  • Type String, HTMLElement
  • Default: null

Specifies a target element where QColorpicker will be moved from original layout place. (has to be a valid query selector, or an HTMLElement).

<q-color-picker
  v-model="modelValue"
  teleport-to="body"
/>


 

1
2
3
4

Events

update:modelValue

Triggers when model updates.

change

Alias for update:modelValue.

Slots

trigger

Optional. HTML element that triggers dropdown

<q-color-picker v-model="color">
  <template v-slot:trigger>
    <q-button size="small">Custom trigger</q-button>
  </template>
</q-color-picker>

 
 
 

1
2
3
4
5
Last Updated:
Contributors: Tim Bochkarev, ViZhe