Skip to main content
Tw Twintrinsic
  • Getting Started
  • Components
  • Theming
  • Completion
Examples
Data Dashboard Game Map
Core
App
Layout
Accordion AccordionItem Card Container Panel Separator Sidebar Splitter
Navigation
AppHeader BottomBar Breadcrumb BreadcrumbItem Menu MenuItem Tabs Tab TabList TabPanel TreeMenu
Data Display
Avatar AvatarGroup Badge Carousel CarouselItem Chip ChipGroup CodeBlock CodeBlockSpeed CodeEditor DataTable Map Progress Skeleton Table TableBody TableCell TableHead TableHeader TableRow Tag TagGroup Timeline TimelineItem Tooltip Tree TreeNode
Metrics
DonutChart PieChart LineChart BarChart HorizontalBarChart AreaChart StatsCard MetricGrid KPICard GaugeChart ProgressMetric MetricTrend
Form
AutoComplete Button ButtonGroup Calendar Checkbox ColorPicker Combobox Dropdown FileUpload FloatLabel Form FormField Input InputSwitch InvalidState Knob ListInput Listbox NumberInput Radio RadioGroup Rating Select SelectGroup Slider Switch TextInput Textarea
Feedback
Modal Stepper StepperStep Toast
Utility
Icon Lazy LazyPanel Masonry ThemeToggle

ColorPicker

The ColorPicker component provides an intuitive interface for color selection, supporting multiple color formats (HEX, RGB, HSL) with optional alpha channel. It includes a color wheel for hue and saturation selection, sliders for lightness and alpha, and direct color value input.

Examples

Basic Usage

<ColorPicker label="Color" />

With Initial Value

<ColorPicker
  label="Color"
  value="#FF0000"
/>

RGB Format

<ColorPicker
  label="Color"
  format="rgb"
  value="rgb(255, 0, 0)"
/>

With Alpha Channel

<ColorPicker
  label="Color"
  format="rgba"
  showAlpha={true}
  value="rgba(255, 0, 0, 0.5)"
/>

HSL Format

<ColorPicker
  label="Color"
  format="hsl"
  value="hsl(0, 100%, 50%)"
/>

With Error

<ColorPicker
  label="Color"
  error="Please select a valid color"
/>

Theme Colors

<ColorPicker
  label="Primary Color"
  value="rgb(var(--color-primary-500))"
  format="rgb"
/>
<ColorPicker
  label="Secondary Color"
  value="rgb(var(--color-secondary-500))"
  format="rgb"
/>

Props

PropTypeDefaultDescription
valuestring'#000000'Color value in current format
format'hex' | 'rgb' | 'rgba' | 'hsl' | 'hsla''hex'Color format
showAlphabooleanfalseWhether to show alpha channel
labelstring'Color'Input label
disabledbooleanfalseWhether the picker is disabled
errorstring''Error message
classstring''Additional CSS classes

Events

EventDetail TypeDescription
onchange{ value: string }Fired when color value changes

Color Formats

The ColorPicker supports the following color formats:

  • hex - #RRGGBB
  • rgb - rgb(r, g, b)
  • rgba - rgba(r, g, b, a)
  • hsl - hsl(h, s%, l%)
  • hsla - hsla(h, s%, l%, a)

Accessibility

The ColorPicker follows accessibility best practices:

  • Color wheel uses proper ARIA roles and labels
  • Sliders have descriptive labels
  • Color values are displayed in text format
  • Keyboard navigation support
  • High contrast color preview
  • Error states are properly indicated

Keyboard Interaction

  • Enter or Space - Open/close color picker
  • Tab - Navigate through controls
  • Arrow keys - Adjust slider values
  • Escape - Close color picker