---
title: "Color Format Field"
description: "Type one color as hex, RGB, HSL, or HSB. Pick the format in a Select, and the color stays the same."
url: https://gelatinui.com/components/color-format-field
markdown_url: https://gelatinui.com/components/color-format-field.md
access: pro
install: "npx shadcn@latest add @gelatin-ui-pro/color-format-field"
version: "2026-11-09"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Color Format Field

> Type one color as hex, RGB, HSL, or HSB. Pick the format in a Select, and the color stays the same.

Page: https://gelatinui.com/components/color-format-field

## When to use it

Best for: Type one color in the format people pick, with a Select that keeps the color the same.

- Use it when people type or paste exact color values.
- Use `alpha` to add an alpha field.
- Use `name` to send the color as hex with a form.

## When not to use it

- For one hex or channel field, use a [Color Field](https://gelatinui.com/components/color-field.md).
- To pick a color by eye, use a [Color Picker](https://gelatinui.com/components/color-picker.md).

## Notes for agents

- Write the parts: `ColorFormatFieldFormat` (the Select) and `ColorFormatFieldInputs`.
- `onValueChange` runs on each committed change: blur, Enter, or the arrow keys.
- A format change keeps the color. `onFormatChange` runs with the new format.
- Inside a `ColorPicker` with no `value`, it reads and sets the picker color.
- Name the group with `aria-label`. Each field has its own name from `labels`.

## Anatomy

```text
ColorFormatField
├─ ColorFormatFieldFormat (0..n)
├─ ColorFormatFieldInputs (0..n)
└─ ColorFormatFieldError (0..n)
```

## API reference

### ColorFormatField

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `disabled` | `boolean` | false | Turns off the control: no focus, no edits, and the disabled look. |
| `name` | `string` |  | The form name: the form gets the color as hex (`#RRGGBB`, or `#RRGGBBAA` with `alpha`). |
| `readOnly` | `boolean` | false | The user can focus and read the value, but cannot change it. |
| `invalid` | `boolean` | false | Shows the invalid look and sets `aria-invalid`. |
| `value` | `string \| Color` |  | The color (controlled): a string ("#6E56CF", "hsl(250, 55%, 57%)") or a React Aria `Color`. |
| `defaultValue` | `string \| Color` |  | The color at first (uncontrolled). Default `#000000`, or the color of a `ColorPicker` around it. |
| `onValueChange` | `function` |  | Runs on each committed change (blur, Enter, arrow keys), with the new `Color`. |
| `colorFormat` | `"hex" \| "hsb" \| "hsl" \| "rgb"` |  | The format (controlled): `hex`, `rgb`, `hsl`, or `hsb`. |
| `defaultColorFormat` | `"hex" \| "hsb" \| "hsl" \| "rgb"` | "hex" | The format at first (uncontrolled). Default `hex`. |
| `onColorFormatChange` | `function` |  | Runs when people pick another format. The color stays the same. |
| `alpha` | `boolean` | false | Adds an alpha field (0% to 100%) after the other fields. |
| `labels` | `Partial` |  | The words (`COLOR_FORMAT_FIELD_LABELS`), to translate them. Keep the object stable. |

### ColorFormatFieldFormat

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  |  |
| `size` | `ControlSizeAtLeastSm` |  |  |
| `contentProps` | `Omit<SelectContentProps, "children">` |  | Props of the format list (`SelectContent`): `container`, `side`, `align`, `className`... |
| `itemProps` | `function` |  | Props of the row of each format (`SelectItem`), and any `data-*` attribute. |

Also takes every prop of Base UI `Select.Trigger`: https://base-ui.com/react/components/select

### ColorFormatFieldInputs

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `size` | `ControlSizeAtLeastSm` | "default" | The height of each field: `sm` 28, `default` 32, `lg` 36. |

### ColorFormatFieldError

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

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| ColorFormatField | `color-format-field` |  |  |  |
| ColorFormatFieldFormat | `color-format-field-format` |  |  |  |
| ColorFormatFieldInputs | `color-format-field-inputs` |  |  |  |
| ColorFormatFieldError | `color-format-field-error` |  |  |  |

## Usage

Put the format Select before or after the fields.

```tsx title="brand-color.tsx"
import {
  ColorFormatField,
  ColorFormatFieldFormat,
  ColorFormatFieldInputs,
} from "@/components/ui/pro/color-format-field";

export function BrandColor() {
  return (
    <ColorFormatField aria-label="Brand color" defaultValue="#6E56CF">
      <ColorFormatFieldFormat />
      <ColorFormatFieldInputs />
    </ColorFormatField>
  );
}
```

## 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/color-format-field
```

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

## Built on

- [Color Field](https://gelatinui.com/components/color-field.md)
- [Input Group](https://gelatinui.com/components/input-group.md)
- [Select](https://gelatinui.com/components/select.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 Field](https://gelatinui.com/components/color-field.md)
- [Color Picker](https://gelatinui.com/components/color-picker.md)
- [Select](https://gelatinui.com/components/select.md)

## Keyboard

| Keys | Action |
| --- | --- |
| Tab | Moves between the Select and the fields. |
| Up Arrow, Down Arrow | Changes the value of the focused channel field one step. |
| Enter | Commits the typed value. |
