---
title: "Image Palette"
description: "Get the main colors of a photo and pick one, such as an accent for a cover. It shows a loading, error, and empty state."
url: https://gelatinui.com/components/image-palette
markdown_url: https://gelatinui.com/components/image-palette.md
access: pro
install: "npx shadcn@latest add @gelatin-ui-pro/image-palette"
version: "2026-11-09"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Image Palette

> Get the main colors of a photo and pick one, such as an accent for a cover. It shows a loading, error, and empty state.

Page: https://gelatinui.com/components/image-palette

## When to use it

Best for: Get the main colors of a picture and pick one, such as an accent for a cover photo.

- Use it when a color must fit a picture.
- Use `mode="accent"` for the colors that stand out, not the largest areas.
- Use `onPaletteReady` to get all the colors of a new picture.

## When not to use it

- To pick any color, use a [Color Picker](https://gelatinui.com/components/color-picker.md).
- To show a palette you have already, use a [Palette Strip](https://gelatinui.com/components/palette-strip.md).

## Notes for agents

- The site of the picture must send a CORS header. Else the error part shows.
- `count` is 2 to 8. The default is 5.
- It reads a copy of 64px or less on a canvas. A new `count` or `mode` uses the same pixels again.
- The root sets `data-status`: `empty`, `loading`, `error`, or `ready`.
- Inside a `ColorPicker` with no `value`, a pick sets the picker color.

## Anatomy

```text
ImagePalette
├─ ImagePaletteImage (0..n)
├─ ImagePaletteSwatches (0..n)
├─ ImagePaletteStrip (0..n)
├─ ImagePaletteError (0..n)
└─ ImagePaletteEmpty (0..n)
```

## API reference

### ImagePalette

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `src` | `string` |  | The picture to read. Its site must send a CORS header, else the error part shows. |
| `alt` | `string` |  | What the picture shows: the name of the image and of the palette. |
| `count` | `number` | 5 | How many colors to find, 2 to 8. Default 5. |
| `mode` | `ImagePaletteMode` | "share" | `share` (default): the colors the picture is made of, the largest area first. `accent`: the colors that stand out (chroma by share), for a brand or an accent color. |
| `value` | `string \| Color` |  | The picked color (controlled). |
| `defaultValue` | `string \| Color` |  | The picked color at first (uncontrolled). Default: none. |
| `onValueChange` | `function` |  | Runs when people pick a color, with the `Color` and the change details. |
| `onPaletteReady` | `function` |  | Runs when the colors of a new picture are ready (once per `src`). |
| `labels` | `Partial<typeof IMAGE_PALETTE_LABELS>` |  | The words (`IMAGE_PALETTE_LABELS`), to translate them. Keep the object stable. |

### ImagePaletteImage

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `srcSet` | `string` |  | A ready `srcset` for `src` ("a-640.jpg 640w, a-1280.jpg 1280w"), with `sizes`: for files that a server already made at each width. It wins over `loader` and `transformer`. Change it together with `src`: the old picture keeps only its `src` while the new one loads. |
| `width` | `number` |  | The width of the box in px. With `height`, it sets the box ratio before the file loads. |
| `height` | `number` |  |  |
| `fill` | `boolean` |  | Fill the positioned parent (`absolute inset-0`). Give the parent a size. |
| `sizes` | `string` |  | The `sizes` of the srcset: how wide the box is per screen ("(max-width: 640px) 100vw, 33vw"). |
| `loader` | `ImageLoader` |  | Makes the URL of each srcset width, Next.js style. Default: the loader of the nearest `ImageLoaderProvider` (none outside one). |
| `transformer` | `ImageTransformer` |  | An Unpic provider transformer, an alternative to `loader`. |
| `quality` | `number` |  | The quality that `loader` and `transformer` get (1–100). |
| `preload` | `boolean` |  | A picture above the fold (a hero): loads at once with a high fetch priority, and React preloads it (`<link rel="preload">` with the srcset). Default `false`: lazy. |
| `placeholder` | `ReactElement \| ImagePlaceholderKind` |  | What shows while the file loads: `muted` (default, the muted box), `skeleton` (the box with a shimmer band), `blur` (`blurDataURL`, blurred), `color` (`placeholderColor`), `none` (no fill, also on an error: the parent shows), or an element: your own layer under the file until its fade ends (a sharp thumbnail of the same picture). |
| `blurDataURL` | `string` |  | A tiny copy of the picture (10px or less, a data URL) for `placeholder="blur"`. |
| `placeholderColor` | `string` |  | The main color of the picture for `placeholder="color"` (a data color). |
| `position` | `string` |  | The CSS `object-position` of the picture in the box ("top", "30% 60%"). |
| `fade` | `boolean` |  | Fade the file in when it loads. Default `true`. A file the page already loaded, or a server file, shows at once. |
| `onLoadingStatusChange` | `function` |  | Called with the new status: `idle`, `loading`, `loaded`, `error`. |
| `onLoad` | `function` |  |  |
| `onError` | `function` |  |  |
| `className` | `string` |  | The classes of the box (size, corners, ratio). |
| `imgClassName` | `string` |  | The classes of the `<img>`. |
| `style` | `CSSProperties` |  |  |
| `children` | `ReactNode` |  | An `ImageFallback` for the error and the no-`src` box. Default: an icon (none for `alt=""`). With a child, the root is not `role="img"`: the fallback speaks for itself, and an img role would hide its words and controls (a retry button) from screen readers. |
| `fit` | `"contain" \| "cover"` |  |  |
| `rounded` | `"default" \| "full"` |  |  |

### ImagePaletteSwatches

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `aria-label` | `string` |  | Defines a string value that labels the current element. |
| `aria-labelledby` | `string` |  | Identifies the element (or elements) that labels the current element. |
| `aria-describedby` | `string` |  | Identifies the element (or elements) that describes the object. |
| `aria-details` | `string` |  | Identifies the element (or elements) that provide a detailed, extended description for the object. |
| `dir` | `string` |  |  |
| `lang` | `string` |  |  |
| `hidden` | `boolean` |  |  |
| `inert` | `boolean` |  |  |
| `translate` | `"no" \| "yes"` |  |  |
| `suppressHydrationWarning` | `boolean` |  | A React-only flag that suppresses the warning React normally logs when an element's server-rendered content doesn't match the client render during hydration. See React docs. |
| `onClick` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onClickCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onAuxClick` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onAuxClickCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onContextMenu` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onContextMenuCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onDoubleClick` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onDoubleClickCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseDown` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseDownCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseEnter` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseLeave` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseMove` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseMoveCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseOut` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseOutCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseOver` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseOverCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseUp` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onMouseUpCapture` | `MouseEventHandler<HTMLDivElement>` |  |  |
| `onTouchCancel` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onTouchCancelCapture` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onTouchEnd` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onTouchEndCapture` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onTouchMove` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onTouchMoveCapture` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onTouchStart` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onTouchStartCapture` | `TouchEventHandler<HTMLDivElement>` |  |  |
| `onPointerDown` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerDownCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerMove` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerMoveCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerUp` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerUpCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerCancel` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerCancelCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerEnter` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerLeave` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerOver` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerOverCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerOut` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onPointerOutCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onGotPointerCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onGotPointerCaptureCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onLostPointerCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onLostPointerCaptureCapture` | `PointerEventHandler<HTMLDivElement>` |  |  |
| `onScroll` | `UIEventHandler<HTMLDivElement>` |  |  |
| `onScrollCapture` | `UIEventHandler<HTMLDivElement>` |  |  |
| `onWheel` | `WheelEventHandler<HTMLDivElement>` |  |  |
| `onWheelCapture` | `WheelEventHandler<HTMLDivElement>` |  |  |
| `onAnimationStart` | `AnimationEventHandler<HTMLDivElement>` |  |  |
| `onAnimationStartCapture` | `AnimationEventHandler<HTMLDivElement>` |  |  |
| `onAnimationEnd` | `AnimationEventHandler<HTMLDivElement>` |  |  |
| `onAnimationEndCapture` | `AnimationEventHandler<HTMLDivElement>` |  |  |
| `onAnimationIteration` | `AnimationEventHandler<HTMLDivElement>` |  |  |
| `onAnimationIterationCapture` | `AnimationEventHandler<HTMLDivElement>` |  |  |
| `onTransitionCancel` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onTransitionCancelCapture` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onTransitionEnd` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onTransitionEndCapture` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onTransitionRun` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onTransitionRunCapture` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onTransitionStart` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `onTransitionStartCapture` | `TransitionEventHandler<HTMLDivElement>` |  |  |
| `style` | `StyleOrFunction` |  | The inline style for the element. A function may be provided to compute the style based on component state. |
| `render` | `DOMRenderFunction` |  | Overrides the default DOM element with a custom render function. This allows rendering existing components with built-in styles and behaviors such as router links, animation libraries, and pre-styled components. Requirements: - You must render the expected element type (e.g. if `<button>` is expected, you cannot render an `<a>`). - Only a single root DOM element can be rendered (no fragments). - You must pass through props and ref to the underlying DOM element, merging with your own prop as appropriate. |
| `layout` | `"grid" \| "stack"` | 'grid' | Whether the items are arranged in a stack or grid. |
| `className` | `string` |  |  |
| `rounded` | `"default" \| "full"` |  | The corner of every swatch and its ring: `default` (4, 6, 8px) or `full` (a circle). |

### ImagePaletteStrip

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `orientation` | `"horizontal" \| "vertical"` |  | `horizontal` (default) fills the width; `vertical` stacks the parts. |
| `gap` | `boolean` |  | 2px gaps between the parts; each part keeps 2px corners and its own edge. |
| `labels` | `Partial<{ empty: string; }>` |  | The words (`PALETTE_STRIP_LABELS`), to translate them. Keep the object stable. |
| `size` | `"default" \| "lg" \| "sm"` | "sm" |  |

### ImagePaletteError

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### ImagePaletteEmpty

No props of its own: `className`, `children`, and every other prop go to the element it renders.

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| ImagePalette | `image-palette` |  |  |  |
| ImagePaletteImage | `image-palette-image` |  |  |  |
| ImagePaletteSwatches | `image-palette-swatches` |  |  |  |
| ImagePaletteStrip | `image-palette-strip` |  |  |  |
| ImagePaletteError | `image-palette-error` |  |  |  |
| ImagePaletteEmpty | `image-palette-empty` |  |  |  |

## Usage

Compose the picture, the swatches, and the strip in your own layout. Add the error and empty parts, so each state has words.

```tsx title="photo-colors.tsx"
import { useState } from "react";

import {
  ImagePalette,
  ImagePaletteEmpty,
  ImagePaletteError,
  ImagePaletteImage,
  ImagePaletteStrip,
  ImagePaletteSwatches,
} from "@/components/pro/pickers/image-palette";

export function PhotoColors() {
  const [accent, setAccent] = useState("#2F6FDF");
  return (
    <ImagePalette
      src="/photos/peaks-sunrise.webp"
      alt="Mountain peaks over the clouds at sunrise"
      count={6}
      onValueChange={(color) => {
        setAccent(color.toString("hex"));
      }}
    >
      <div className="flex items-center gap-3">
        <ImagePaletteImage className="aspect-square w-16 shrink-0" />
        <div className="flex min-w-0 flex-1 flex-col gap-2">
          <ImagePaletteSwatches rounded="full" />
          <ImagePaletteStrip />
        </div>
      </div>
      <ImagePaletteError />
      <ImagePaletteEmpty />
      <p className="font-mono text-xs text-muted-foreground">Accent {accent}</p>
    </ImagePalette>
  );
}
```

## Compose

Rules:

- Compose the parts (`compose-parts`): Build each item from its named parts as children, and pass your text and icons in as parts.
- Every state is designed (`every-state`): Give each view of data its loading, empty, and error states: a skeleton in the final layout, an `Empty` with an illustration and one next action, and an error that says what failed and how to retry.

## Add it

```bash
npx shadcn@latest add @gelatin-ui-pro/image-palette
```

It adds 43 registry items: 39 files, 6302 lines, and the npm packages `@base-ui/react`, `@mantine/hooks`, `@phosphor-icons/react`, `@unpic/core`, `@xstate/react`, `clsx`, `motion`, `react-aria-components`, `tailwind-merge`, `tailwind-variants`, `xstate`.

## Built on

- [Palette Strip](https://gelatinui.com/components/palette-strip.md)
- [Color Swatch Picker](https://gelatinui.com/components/color-swatch-picker.md)
- [Empty](https://gelatinui.com/components/empty.md)
- [Image](https://gelatinui.com/components/image.md)
- [Skeleton](https://gelatinui.com/components/skeleton.md)

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Color Swatch Picker](https://gelatinui.com/components/color-swatch-picker.md)
- [Palette Strip](https://gelatinui.com/components/palette-strip.md)
- [Color Picker](https://gelatinui.com/components/color-picker.md)
- [Image](https://gelatinui.com/components/image.md)

## Keyboard

| Keys | Action |
| --- | --- |
| Tab | Moves focus to the selected swatch. |
| Arrow keys | Moves to the next color and picks it. |

## Motion

| Part | Motion |
| --- | --- |
| Ready | indicator · 200ms · the swatches fade in together |
