Color-Picker
The TkColorPicker component provides a color selection interface with various
input formats. It supports HEX and RGB color formats with an optional alpha
channel.
- React
- Vue
- Angular
import { TkColorPicker } from '@takeoff-ui/react'
import { TkColorPicker } from '@takeoff-ui/vue'
import { TkColorPicker } from '@takeoff-ui/angular'
Playground
Preview
Generated Code
<TkColorPicker size="base" orientation="vertical" headerType="basic" label="Select Color" value="#326FD1" showAlphaSlider showPresets showFormatSelector/><TkColorPicker size="base" orientation="vertical" headerType="basic" label="Select Color" value="#326FD1" :showAlphaSlider.prop="true" :showPresets.prop="true" :showFormatSelector.prop="true"/><tk-color-picker size="base" orientation="vertical" headerType="basic" label="Select Color" value="#326FD1" [showAlphaSlider]="true" [showPresets]="true" [showFormatSelector]="true"/>Controls
Basic
The default TkColorPicker renders with a trigger input that displays the
selected color. Clicking the trigger opens a panel where users can select colors
using the saturation area, hue slider, and direct value inputs.
- React
- Vue
- Angular
const [color, setColor] = useState('#326FD1');
<TkColorPicker
label="Select Color"
showAsterisk
value={color}
onTkChange={(e) => setColor(e.detail)}
/>
<script setup>
import { TkColorPicker } from '@takeoff-ui/vue';
import { ref } from 'vue';
const color = ref('#326FD1');
</script>
<template>
<TkColorPicker
label="Select Color"
showAsterisk
v-model="color"
/>
</template>
<tk-color-picker
label="Select Color"
[show-asterisk]="true"
[value]="color"
(tkChange)="onColorChange($event)">
</tk-color-picker>
Inline Mode
Set inline to display the color picker panel directly without a trigger
element. This is ideal for settings pages, theme builders, or anywhere the color
picker should always be visible.
- React
- Vue
- Angular
<TkColorPicker inline />
<TkColorPicker inline />
<tk-color-picker inline></tk-color-picker>
Header Types
The headerType prop allows you to customize the header appearance. Available
options are basic, divided, light, dark, and primary. Each type
provides a distinct visual style to match your application's design language.
- React
- Vue
- Angular
Footer Types
The footer is slot-based and only renders when you provide content via footer
or footer-actions slots. Use the footerType prop to style the footer
container with basic, divided, or light variants. Use the apply() and
cancel() methods to handle user actions programmatically.
Selected color: #C79807
- React
- Vue
- Angular
Controlled Closing
Use preventDismiss and showCloseButton props to control how the panel can be
closed. When preventDismiss is true, clicking outside the panel won't close
it - users must use the provided action buttons. Set showCloseButton to
false to hide the header close icon, forcing users to interact with footer
actions.
- React
- Vue
- Angular
const [color, setColor] = useState('#326FD1');
const pickerRef = useRef<HTMLTkColorPickerElement>(null);
const handleApply = () => {
pickerRef.current?.apply();
};
const handleCancel = () => {
pickerRef.current?.cancel();
};
<TkColorPicker
ref={pickerRef}
label="Select Color"
value={color}
preventDismiss
showCloseButton={false}
onTkChange={(e) => setColor(e.detail)}
>
<div slot="footer-actions">
<TkButton label='Cancel' variant="secondary" size="small" onTkClick={handleCancel}>
</TkButton>
<TkButton label='Apply' variant="primary" size="small" onTkClick={handleApply}>
</TkButton>
</div>
</TkColorPicker>
<script setup>
import { TkColorPicker, TkButton } from '@takeoff-ui/vue';
import { ref } from 'vue';
const color = ref('#326FD1');
const pickerRef = ref(null);
const handleApply = () => {
pickerRef.value?.apply();
};
const handleCancel = () => {
pickerRef.value?.cancel();
};
</script>
<template>
<TkColorPicker
ref="pickerRef"
label="Select Color"
v-model="color"
preventDismiss
:showCloseButton="false"
>
<div slot="footer-actions">
<TkButton label='Cancel' variant="secondary" size="small" @tk-click="handleCancel">
</TkButton>
<TkButton label='Apply' variant="primary" size="small" @tk-click="handleApply">
</TkButton>
</div>
</TkColorPicker>
</template>
@ViewChild('colorPicker') colorPicker: ElementRef<HTMLTkColorPickerElement>;
handleApply() {
this.colorPicker.nativeElement.apply();
}
handleCancel() {
this.colorPicker.nativeElement.cancel();
}
<tk-color-picker
#colorPicker
label="Select Color"
[value]="color"
[prevent-dismiss]="true"
[show-close-button]="false"
(tkChange)="onColorChange($event)">
<div slot="footer-actions">
<tk-button label='Cancel' variant="secondary" size="small" (tkClick)="handleCancel()">
</tk-button>
<tk-button label='Apply' variant="primary" size="small" (tkClick)="handleApply()">
</tk-button>
</div>
</tk-color-picker>
Orientation
The component supports two panel layouts via the orientation prop. The default
vertical layout places the saturation area above the controls, while
horizontal arranges them side by side for a more compact footprint.
Vertical
Horizontal
- React
- Vue
- Angular
<TkColorPicker inline orientation="vertical" />
<TkColorPicker inline orientation="horizontal" />
<TkColorPicker inline orientation="vertical" />
<TkColorPicker inline orientation="horizontal" />
<tk-color-picker inline orientation="vertical"></tk-color-picker>
<tk-color-picker inline orientation="horizontal"></tk-color-picker>