Knit UI
GitHub

Playground

Loading playground…

true
false
true
Playground
<ColorPicker
  defaultValue="#228be6"
  format="hex"
  size="md"
  withPicker
  fullWidth={false}
  focusable
/>

Examples

Sizes

All seven sizes displayed side by side to compare the picker footprint.

Loading example…

SizesSourceStorybook

Shadows

The inherited shadow elevation ladder, from xs to xl.

Loading example…

ShadowsSourceStorybook

Alpha Format

Alpha formats (hexa / rgba / hsla) add an alpha slider and a preview swatch.

Loading example…

Alpha FormatSourceStorybook

With Swatches

Predefined swatch grid shown below the picker — clicking a swatch jumps to that color.

Loading example…

With SwatchesSourceStorybook

Swatches Only

Hides the saturation / hue controls; only the swatch grid is rendered.

Loading example…

Swatches OnlySourceStorybook

Accessible Labels

Accessible labels wired to the saturation, hue, and alpha sliders for screen readers.

Loading example…

Accessible LabelsSourceStorybook

Styles

Per-slot styles targets individual parts — here the saturation area, hueSlider, and thumb.

Loading example…

StylesSourceStorybook

Controlled

Controlled picker — current color value is displayed and kept in sync via React state.

Loading example…

ControlledSourceStorybook

Props

PropTypeDefaultDescription
alphaLabelstring | undefined—Alpha slider `aria-label`.
childrenReactNode—`ColorPicker.Saturation` / `.HueSlider` / `.Swatches` etc.
defaultValuestring | undefined'#FFFFFF'Uncontrolled initial value.
disabled systemboolean | undefined——
focusableboolean | undefinedtrueWhether slider thumbs are keyboard-focusable.
formatColorFormat | undefined
hex · hexa · rgb · rgba · hsl · hsla
'hex'Output color format. Alpha formats (hexa / rgba / hsla) also render the alpha slider.
fullWidth systemboolean | undefinedfalseTake 100% of the container width.
hueLabelstring | undefined—Hue slider `aria-label`.
namestring | undefined—Hidden input `name`, for uncontrolled form submission (web).
onChange((value: string) => void) | undefined—Called on every value change while dragging / typing.
onChangeEnd((value: string) => void) | undefined—Called once a slider drag / keyboard change finishes.
onColorSwatchClick((color: string) => void) | undefined—Called when a swatch is clicked.
saturationLabelstring | undefined—Saturation area `aria-label`.
shadow system"xs" | "sm" | "md" | "lg" | "xl" | "xxs" | "xxl" | undefined——
size system"xs" | "sm" | "md" | "lg" | "xl" | "xxs" | "xxl" | undefined
xxs · xs · sm · md · lg · xl · xxl
'md'Controls the overall width and the height of the saturation / slider areas.
styles systemSlotStyles<ColorPickerStyles> | undefined—Per-slot style sugar — shared to the parts.
swatchesstring[] | undefined—Predefined colors shown as a swatch grid below the picker.
swatchesPerRownumber | undefined7Number of swatches per row (drives the auto swatch cell size).
theme systemThemeName | null | undefined—Applies a theme to this element
valuestring | undefined—Controlled value (any valid CSS color string).
withPickerboolean | undefinedtrueWhen false only the swatch grid is shown — no saturation or hue controls.

Style slots

Every part of ColorPicker can be styled through the styles prop. Explicit props on the component always win over slot styles.

SlotTargets
alphaSliderProps for the alpha slider track (ColorPicker.AlphaSlider).
hueSliderProps for the hue slider track (ColorPicker.HueSlider).
previewProps for the alpha preview swatch (ColorPicker.Preview).
rootProps for the outer wrapper (ColorPicker.Frame → PickerWrapper).
saturationProps for the saturation area frame (ColorPicker.Saturation).
swatchProps for each predefined swatch (ColorPicker.Swatch).
swatchesProps for the swatch grid container (ColorPicker.Swatches).
thumbProps for every drag handle (the saturation + slider thumbs).
Accessibility & DOM props (2)
PropType
keyKey | null | undefined
refRef<(HTMLElement & TamaguiElementMethods) | View> | undefined

Plus 495 inherited style props from Box — the full Tamagui/React Native style surface, including token shorthands like p, mx, bg and c. See Tokens for the scales they accept, or the full list.

Edit this page on GitHub