React Native · Components
ColorPicker
Color picker (same API as ColorPicker on web).
Live example
The preview runs in the browser with the web component; the native component takes the same props and looks the same on iOS and Android.
Preview
Code
Events
- Events appear here when you interact with the preview.
Inline, OKLCH and opacity
Theme colors: a chosen var(--ui-*) changes with the theme
Readable text color (WCAG contrast)
ColorSwatch: for showing in tables and lists
Import
ColorPicker
componentColor picker (same API as ColorPicker on web). Tapping the box opens a panel with a saturation/brightness area, hue and opacity sliders, a color input and swatches; on a phone it is a bottom sheet.
- Formats: The value is returned in the
formatformat (hex,rgb,hsl,oklch). The text field understands every format; the format button changes the display. - Theme:
swatches="theme"offers theme colors; the pickedvar(--ui-*)value is returned as is (the same value as on web) and is drawn with each theme's own color. - Touch: Dragging is claimed as soon as the touch starts; a bottom sheet or scroll view does not interfere. With a screen reader the area and sliders are adjusted by swiping up/down.
- Hue is preserved: The hue is not lost when going down to gray or black.
- Form: Binds inside a
Formwithname.
Picking a color from the screen (eyedropper) on web is not available on mobile platforms.
Examples
ColorField
componentColorPicker with label, description and error (ColorField on web). On native every field is already drawn with a label/error frame, so it is the same as ColorPicker; it exists so code ported from web works unchanged.
Examples
ColorSwatch
componentShows a color in a small box (ColorSwatch on web). Transparent colors are drawn over a checkerboard; an empty value is shown with a "no color" stripe. Theme colors are resolved against the active theme.
Examples
COLOR_FORMATS
constantSupported formats, in picker order.
rgbToHsv
functionRGB → HSV. Grays return hue 0; to keep the hue see keepHue.
THEME_SWATCHES
constantTheme colors: swatches="theme" shows this list. The values are the same as on web (var(--ui-*)); on native resolveColor turns them into the active theme's colors.
hsvToRgb
functionHSV → RGB (fractional channels; rounded when written).
DEFAULT_SWATCHES
constantDefault swatches (same as web): the palette's 500 shades, white and black.
rgbToHsl
functionRGB → HSL (h 0–360, s/l 0–1).
hslToRgb
functionHSL → RGB.
rgbToOklch
functionRGB → OKLCH (l 0–1, c ~0–0.4, h 0–360).
oklchToRgb
functionOKLCH → RGB.
resolveColor
functionParses a color string. In addition to what parseColor understands, it also understands theme colors: var(--ui-primary) (the same notation as on web) or just the name ("primary", "muted-foreground"). These are turned into the given theme's color.
keepHue
functionKeeps the hue (and saturation on black) from the previous value when the new HSV value loses it. A picker dragged to gray or black does not jump to red.
parseColor
functionParses a color string. Supported forms: #rgb, #rgba, #rrggbb, #rrggbbaa (with or without #), rgb()/rgba(), hsl()/hsla(), hwb(), oklch(), oklab(), color(srgb …) (comma and space separated, with percentage and angle units) and transparent.
For forms the browser has to resolve, such as names (red) and theme variables (var(--ui-primary)), see resolveCssColor.
Examples
isColor
functionIs the string a valid color? See parseColor.
detectColorFormat
functionFormat the string is written in; undefined when unknown.
formatColor
functionWrites a color in the requested format. See ColorFormat.
Examples
convertColor
functionConverts a string to another format; undefined when it cannot be parsed.
Examples
luminance
functionWCAG relative luminance (0 black – 1 white).
contrastRatio
functionWCAG contrast ratio of two colors (1–21). At least 4.5 is recommended for normal text, 3 for large text. 1 when a color cannot be parsed.
Examples
readableColor
functionA readable text color on a color background: "#000000" or "#ffffff" (whichever has the higher contrast).
Rgba
interfacesRGB color: channels 0–255 (may be fractional), alpha 0–1. See parseColor, formatColor.
| Name | Type | Description |
|---|---|---|
r | number | Red, 0–255. |
g | number | Green, 0–255. |
b | number | Blue, 0–255. |
a | number | Alpha: 0 fully transparent, 1 fully opaque. |
ColorSwatchOption
interfaceA color in the swatch list.
| Name | Type | Description |
|---|---|---|
value | string | Color string: #3b82f6, oklch(0.62 0.19 260) or a theme color var(--ui-primary). When picked, the value is returned as is; theme colors follow the theme when it changes (the same values as on web). |
label? | string | Screen reader name. Defaults to name's translation, then value. |
name? | ColorName | A built-in color name; its text comes from the colorNames messages (used by THEME_SWATCHES and DEFAULT_SWATCHES). |
Hsva
interfaceHSV (hue, saturation, value) color: the color picker's internal model. h 0–360, s and v 0–1, a 0–1.
| Name | Type | Description |
|---|---|---|
h | number | Hue, 0–360 degrees. |
s | number | Saturation, 0–1. |
v | number | Value (brightness), 0–1. |
a | number | Alpha, 0–1. |
ColorFormat
typeFormat of a color string.
"hex":#3b82f6(with alpha#3b82f680)"rgb":rgb(59 130 246)(with alphargb(59 130 246 / 0.5))"hsl":hsl(217 91% 60%)"oklch":oklch(0.623 0.188 259.8): perceptually even steps; the library's themes use this format.
FormatColorOptions
interfaceformatColor options.
| Name | Type | Default | Description |
|---|---|---|---|
alpha? | boolean | "auto" | "auto" | Write the alpha? "auto" writes it only when the color is transparent; false drops the alpha. |
ColorPickerProps
interfaceProps of ColorPicker (same names as on web).
Extends: FieldProps
| Name | Type | Default | Description |
|---|---|---|---|
value? | string | Color in controlled use; "" when there is no color. | |
defaultValue? | string | Initial color in uncontrolled use. | |
onValueChange? | (value: string) => void | When the color changes; on every step while dragging. The value is in the format format; theme colors from a swatch (var(--ui-*)) are returned as is. | |
onValueCommit? | (value: string) => void | When a selection is complete: when dragging ends, a swatch is picked or a typed color is confirmed. Use this to save to a server. | |
format? | ColorFormat | "hex" | Format of the returned value. |
alpha? | boolean | false | Show an opacity slider and include it in the value? |
formats? | readonly ColorFormat[] | ["hex", "rgb", "hsl", "oklch"] | Formats the format button in the text field cycles through. With a single format the button is hidden. |
swatches? | readonly (string | ColorSwatchOption)[] | "theme" | false | Swatches: an array of strings or { value, label }; "theme" for theme colors (THEME_SWATCHES); false hides them. Defaults to DEFAULT_SWATCHES. | |
recent? | boolean | string | false | Remember recently picked colors (at most 8, stored on the device). true shares one list across all pickers; a string keeps a separate list under that key. |
inline? | boolean | false | Show the picker inline in the page instead of a popover. |
placeholder? | string | "Renk seç" | Text shown in the box when empty. |
clearable? | boolean | true | Clear button. |
readOnly? | boolean | Read-only: the color is visible but cannot be changed. | |
open? | boolean | Whether the panel is open in controlled use. | |
onOpenChange? | (open: boolean) => void | When the panel opens or closes. | |
variant? | FieldVariant | "outline" | Field appearance. |
aria-label? | string | Screen reader name; give it when there is no visible label. | |
style? | StyleProp<ViewStyle> | Container style. |
ColorFieldProps
typeProps of ColorField: the same as ColorPickerProps.
Extends: FieldProps
| Name | Type | Default | Description |
|---|---|---|---|
value? | string | Color in controlled use; "" when there is no color. | |
defaultValue? | string | Initial color in uncontrolled use. | |
onValueChange? | (value: string) => void | When the color changes; on every step while dragging. The value is in the format format; theme colors from a swatch (var(--ui-*)) are returned as is. | |
onValueCommit? | (value: string) => void | When a selection is complete: when dragging ends, a swatch is picked or a typed color is confirmed. Use this to save to a server. | |
format? | ColorFormat | "hex" | Format of the returned value. |
alpha? | boolean | false | Show an opacity slider and include it in the value? |
formats? | readonly ColorFormat[] | ["hex", "rgb", "hsl", "oklch"] | Formats the format button in the text field cycles through. With a single format the button is hidden. |
swatches? | readonly (string | ColorSwatchOption)[] | "theme" | false | Swatches: an array of strings or { value, label }; "theme" for theme colors (THEME_SWATCHES); false hides them. Defaults to DEFAULT_SWATCHES. | |
recent? | boolean | string | false | Remember recently picked colors (at most 8, stored on the device). true shares one list across all pickers; a string keeps a separate list under that key. |
inline? | boolean | false | Show the picker inline in the page instead of a popover. |
placeholder? | string | "Renk seç" | Text shown in the box when empty. |
clearable? | boolean | true | Clear button. |
readOnly? | boolean | Read-only: the color is visible but cannot be changed. | |
open? | boolean | Whether the panel is open in controlled use. | |
onOpenChange? | (open: boolean) => void | When the panel opens or closes. | |
variant? | FieldVariant | "outline" | Field appearance. |
aria-label? | string | Screen reader name; give it when there is no visible label. | |
style? | StyleProp<ViewStyle> | Container style. |
ColorSwatchProps
interfaceProps of ColorSwatch.
| Name | Type | Default | Description |
|---|---|---|---|
color | string | undefined | Color to show (any format, or a theme color like var(--ui-primary)). When empty, a diagonally striped "no color" box is drawn. | |
size? | "sm" | "md" | "lg" | "md"` (20 px) | Size. |
shape? | "rounded" | "circle" | "square" | "rounded" | Corner shape. |
label? | string | Screen reader name. If omitted it is decorative (screen readers skip it). | |
style? | StyleProp<ViewStyle> | Container style. |