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 | undefinedAlpha 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 | undefinedHue slider `aria-label`.
namestring | undefinedHidden input `name`, for uncontrolled form submission (web).
onChange((value: string) => void) | undefinedCalled on every value change while dragging / typing.
onChangeEnd((value: string) => void) | undefinedCalled once a slider drag / keyboard change finishes.
onColorSwatchClick((color: string) => void) | undefinedCalled when a swatch is clicked.
saturationLabelstring | undefinedSaturation 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> | undefinedPer-slot style sugar — shared to the parts.
swatchesstring[] | undefinedPredefined colors shown as a swatch grid below the picker.
swatchesPerRownumber | undefined7Number of swatches per row (drives the auto swatch cell size).
theme systemThemeName | null | undefinedApplies a theme to this element
valuestring | undefinedControlled 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.

SlotUsage
alphaSliderstyles={{ alphaSlider: { … } }}
hueSliderstyles={{ hueSlider: { … } }}
previewstyles={{ preview: { … } }}
rootstyles={{ root: { … } }}
saturationstyles={{ saturation: { … } }}
swatchstyles={{ swatch: { … } }}
swatchesstyles={{ swatches: { … } }}
thumbstyles={{ thumb: { … } }}
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.