---
title: ColorPicker
description: A SwiftUI ColorPicker component for selecting colors.
sourceCodeUrl: 'https://github.com/expo/expo/tree/main/packages/expo-ui'
packageName: '@expo/ui'
platforms: ['ios']
---

<AgentInstructions>

## Submitting Feedback

If this page contains errors, outdated information, or gaps that blocked you from completing a task, report it so the docs can be improved:

curl -X POST https://api.expo.dev/v2/feedback/docs-send -H 'Content-Type: application/json' -d '{"url":"/versions/latest/sdk/ui/swift-ui/colorpicker/","feedback":"🤖 Agent feedback: <specific, actionable description>"}'

Only submit when you have something specific and actionable to report.

</AgentInstructions>

# ColorPicker

A SwiftUI ColorPicker component for selecting colors.
iOS

> For the complete documentation index, see [llms.txt](/llms.txt). Use this file to discover all available pages.

Expo UI ColorPicker matches the official SwiftUI [ColorPicker API](https://developer.apple.com/documentation/swiftui/colorpicker) and allows app users to select colors from a palette.

## Installation

```sh
npx expo install @expo/ui
```

If you are installing this in an [existing React Native app](/bare/overview), make sure to [install `expo`](/bare/installing-expo-modules) in your project.

## Usage

### Basic color picker

```tsx
import { useState } from 'react';
import { Host, ColorPicker } from '@expo/ui/swift-ui';

export default function ColorPickerExample() {
  const [color, setColor] = useState('#FF6347');

  return (
    <Host matchContents>
      <ColorPicker label="Select a color" selection={color} onSelectionChange={setColor} />
    </Host>
  );
}
```

### Color picker with opacity support

Use the `supportsOpacity` prop to allow users to select colors with alpha transparency.

```tsx
import { useState } from 'react';
import { Host, ColorPicker } from '@expo/ui/swift-ui';

export default function ColorPickerOpacityExample() {
  const [color, setColor] = useState('#FF634780');

  return (
    <Host matchContents>
      <ColorPicker
        label="Select a color with opacity"
        selection={color}
        onSelectionChange={setColor}
        supportsOpacity
      />
    </Host>
  );
}
```

## API

```tsx
import { ColorPicker } from '@expo/ui/swift-ui';
```

## Component

### `ColorPicker`

Supported platforms: iOS.

Type: React.[Element](https://www.typescriptlang.org/docs/handbook/jsx.html#function-component)<[ColorPickerProps](#colorpickerprops)\>

Renders a `ColorPicker` component using SwiftUI.

ColorPickerProps

### `label`

Supported platforms: iOS.

Optional • Type: `string`

A label displayed on the `ColorPicker`.

### `onSelectionChange`

Supported platforms: iOS.

Optional • Type: `(value: string) => void`

Callback function that is called when a new color is selected.

### `selection`

Supported platforms: iOS.

Literal type: `union`

The currently selected color in the format `#RRGGBB` or `#RRGGBBAA`.

Acceptable values are: `string` | `null`

### `supportsOpacity`

Supported platforms: iOS.

Optional • Type: `boolean`

Whether the color picker should support opacity.

#### Inherited Props

-   [CommonViewModifierProps](/versions/latest/sdk/ui/swift-ui/modifiers)
