---
title: "Saved Colors"
description: "Keep the colors a person uses again at the foot of a Color Picker. Add saves the current color, and the list can stay in local storage."
url: https://gelatinui.com/components/saved-colors
markdown_url: https://gelatinui.com/components/saved-colors.md
access: pro
install: "npx shadcn@latest add @gelatin-ui-pro/saved-colors"
version: "2026-11-09"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Saved Colors

> Keep the colors a person uses again at the foot of a Color Picker. Add saves the current color, and the list can stay in local storage.

Page: https://gelatinui.com/components/saved-colors

## When to use it

Best for: Keep the colors a person uses again, at the foot of a Color Picker.

- Use it in a `ColorPicker` popover, where Add saves the current color.
- Use `storageKey` to keep the list in `localStorage` after a reload.
- Use `colors` and `onColorsChange` when your app saves the list.

## When not to use it

- For a fixed set of colors, use a [Color Swatch Picker](https://gelatinui.com/components/color-swatch-picker.md).
- For a large set of hues, use a [Color Grid](https://gelatinui.com/components/color-grid.md).

## Notes for agents

- Colors are saved as `#RRGGBB`, or `#RRGGBBAA` when they are see-through.
- `max` is 7 by default. Add turns off at it.
- Add selects a color that is saved already. It never saves it twice.
- Outside a `ColorPicker`, give `SavedColorsAdd` a `color`.
- With `storageKey`, the first render shows `defaultColors`, because the server cannot read `localStorage`.

## Anatomy

```text
SavedColors
├─ SavedColorsList (0..n)
├─ SavedColorsAdd (0..n)
├─ SavedColorsRemove (0..n)
├─ SavedColorsLabel (0..n)
└─ SavedColorsEmpty (0..n)
```

## API reference

### SavedColors

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `size` | `"default" \| "lg" \| "sm"` | "default" | The size of the swatches and of Add: `sm` 16, `default` 24, `lg` 32. A part prop wins. |
| `rounded` | `"default" \| "full"` | "full" | The corner of the swatches and of Add: `full` (default, circles) or `default`. |
| `colors` | `readonly string[]` |  | The saved colors (controlled), `#RRGGBB` or `#RRGGBBAA`. |
| `defaultColors` | `readonly string[]` | NO_COLORS | The saved colors at first (uncontrolled), and on the server with a `storageKey`. |
| `onColorsChange` | `function` |  | Runs when a color is saved or removed, with the new list. |
| `max` | `number` | 7 | The most colors the list keeps: `SavedColorsAdd` turns off at it. Default 7, one row of 24px swatches in a 248px popover. |
| `storageKey` | `string` |  | Keeps the uncontrolled list in `localStorage` under this key, and in every tab with the same key. |

### SavedColorsList

| 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` |  |  |
| `size` | `"default" \| "lg" \| "sm"` |  | The size of every swatch: `sm` 16, `default` 24, `lg` 32. |
| `rounded` | `"default" \| "full"` |  | The corner of every swatch and its ring: `default` (4, 6, 8px) or `full` (a circle). |

### SavedColorsAdd

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `size` | `"default" \| "lg" \| "sm"` |  | The size of Add. Default: the `size` of `SavedColors`, the size of its swatches. |
| `rounded` | `"default" \| "full"` |  | The corner of Add. Default: the `rounded` of `SavedColors`. |
| `color` | `string \| Color` |  | The color to save. Default: the color of the surrounding `ColorPicker`. |

Also takes every prop of Base UI `Button`: https://base-ui.com/react/components/button

### SavedColorsLabel

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

### SavedColorsEmpty

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

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| SavedColors | `saved-colors` |  |  |  |
| SavedColorsList | `saved-colors-list` | `data-empty` |  |  |
| SavedColorsAdd | `saved-colors-add` | `data-disabled` |  | `hit-area`, `motion-timing` |
| SavedColorsRemove | `saved-colors-remove` |  |  |  |
| SavedColorsLabel | `saved-colors-label` |  |  |  |
| SavedColorsEmpty | `saved-colors-empty` |  |  |  |

## Usage

In a `ColorPicker`, Add saves the picker color. Compose the label, Remove, the list, Add, and the empty words, and set `storageKey` to keep the list.

The sample also uses `color-picker`, which this add does not write. One command adds them with this item:

```bash
npx shadcn@latest add @gelatin-ui-pro/saved-colors @gelatin-ui/color-picker
```

```tsx title="label-color.tsx"
import { ColorPicker, ColorPickerContent, ColorPickerTrigger } from "@/components/ui/color-picker";
import {
  SavedColors,
  SavedColorsAdd,
  SavedColorsEmpty,
  SavedColorsLabel,
  SavedColorsList,
  SavedColorsRemove,
} from "@/components/ui/pro/saved-colors";

export function LabelColor() {
  return (
    <ColorPicker defaultValue="#6E56CF">
      <ColorPickerTrigger aria-label="Label color" />
      <ColorPickerContent>
        <SavedColors storageKey="label-colors">
          <div className="flex min-h-6 items-center justify-between gap-2">
            <SavedColorsLabel>Your colors</SavedColorsLabel>
            <SavedColorsRemove />
          </div>
          <div className="flex flex-wrap items-center gap-2 pointer-coarse:gap-5">
            <SavedColorsList />
            <SavedColorsAdd />
            <SavedColorsEmpty>Save a color to use it on every label</SavedColorsEmpty>
          </div>
        </SavedColors>
      </ColorPickerContent>
    </ColorPicker>
  );
}
```

## 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/saved-colors
```

It adds 29 registry items: 25 files, 4671 lines, and the npm packages `@base-ui/react`, `@mantine/hooks`, `@phosphor-icons/react`, `clsx`, `motion`, `react-aria-components`, `tailwind-merge`, `tailwind-variants`.

## Built on

- [Button](https://gelatinui.com/components/button.md)
- [Color Swatch](https://gelatinui.com/components/color-swatch.md)
- [Color Swatch Picker](https://gelatinui.com/components/color-swatch-picker.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 Picker](https://gelatinui.com/components/color-picker.md)
- [Color Swatch Picker](https://gelatinui.com/components/color-swatch-picker.md)
- [Color Grid](https://gelatinui.com/components/color-grid.md)

## Keyboard

| Keys | Action |
| --- | --- |
| Arrow keys | Moves to the next saved color and selects it. |
| Delete, Backspace | Removes the focused color and moves focus to the next one. |

## Motion

| Part | Motion |
| --- | --- |
| Add | indicator · 200ms · the new swatch grows from 0.5 and fades in |
| Remove | indicator · 200ms · the swatch fades out to 0.5, then the row closes up |
