

<InteractiveDemo
  name="color-area"
  controls="[
  {
    type: &#x22;boolean&#x22;,
    name: &#x22;isDisabled&#x22;,
    defaultValue: false,
  },
]"
/>

## Installation [#installation]

<InstallPrerequisite>
  Before adding components, init your project with your design system from the [Studio](/studio).
</InstallPrerequisite>

<CodeBlockTabs defaultValue="npm" groupId="package-manager">
  <CodeBlockTabsList>
    <CodeBlockTabsTrigger value="npm">
      npm
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="pnpm">
      pnpm
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="yarn">
      yarn
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="bun">
      bun
    </CodeBlockTabsTrigger>
  </CodeBlockTabsList>

  <CodeBlockTab value="npm">
    ```bash
    npx shadcn@latest add @dotui/color-area
    ```
  </CodeBlockTab>

  <CodeBlockTab value="pnpm">
    ```bash
    pnpm dlx shadcn@latest add @dotui/color-area
    ```
  </CodeBlockTab>

  <CodeBlockTab value="yarn">
    ```bash
    yarn dlx shadcn@latest add @dotui/color-area
    ```
  </CodeBlockTab>

  <CodeBlockTab value="bun">
    ```bash
    bunx shadcn@latest add @dotui/color-area
    ```
  </CodeBlockTab>
</CodeBlockTabs>

## Usage [#usage]

```tsx
import { ColorArea } from "@/components/ui/color-area"
import { ColorThumb } from "@/components/ui/color-thumb"
```

```tsx
<ColorArea>
  <ColorThumb />
</ColorArea>
```

## Anatomy [#anatomy]

A `ColorArea` renders the gradient and positions a `ColorThumb`. If you omit children, a default `ColorThumb` is rendered for you.

```tsx
import { ColorArea } from "@/components/ui/color-area"
import { ColorThumb } from "@/components/ui/color-thumb"
```

```tsx
<ColorArea>
  <ColorThumb />
</ColorArea>
```

## Value [#value]

Use `defaultValue` for uncontrolled state, or `value` with `onChange` to control it. Uncontrolled values accept a color string; controlled values are `Color` objects created with `parseColor`.

```tsx
import { parseColor } from 'react-aria-components'

const [value, setValue] = React.useState(parseColor('hsl(0, 100%, 50%)'))

<ColorArea value={value} onChange={setValue} />
```

## Channels [#channels]

`xChannel` and `yChannel` map two channels of the color to the horizontal and vertical axes of the gradient.

```tsx
<ColorArea xChannel="saturation" yChannel="lightness" />
```

## Examples [#examples]

<Examples className="sm:grid-cols-2">
  <Example name="color-area/demos/default" title="Default" />

  <Example name="color-area/demos/brand-color" title="Brand Color Picker" />

  <Example name="color-area/demos/theme-customizer" title="Theme Customizer" className="col-span-full" />
</Examples>

## API Reference [#api-reference]

### ColorArea [#colorarea]

<Reference name="color-area" />

### ColorThumb [#colorthumb]

<Reference name="color-thumb" />
