# <color-picker>

A color picker: a hue ring round a disc, with swatches; the chosen color goes into a variable.

Category: Forms and input. Also written `<colour-picker>`.

```ham
<column style="gap-12 items-center">
    <color-picker id="pick"
                  name="color"
                  value="#C8553D"
                  size="200"
                  palette="#C8553D,#E09F3E,#335C67,#FFFFFF,#000000"/>
    <text @text="'Chosen: ' + $color"></text>
</column>
```

How Hype Apps draws it on a phone: [light](https://hypeapps.dev/img/tags/color-picker-light.webp), [dark](https://hypeapps.dev/img/tags/color-picker-dark.webp).

## Attributes

| Name | What it does | Default |
|---|---|---|
| `mode` | disc: a hue ring round a saturation/brightness disc; classic: a saturation/brightness square with a hue bar; sliders: hue, saturation and brightness sliders; palette: the swatches only. (disc, classic, sliders, palette) | `disc` |
| `name` | Variable name for form scoping; holds the hex. |  |
| `palette` | Comma-separated swatches shown under the picker (all of palette mode); a tap picks one. |  |
| `recent` | Keep the last N colors picked as a row of swatches, newest first ($id.recent). | `0` |
| `size` | The disc's / square's / sliders' width in px. | `240` |
| `value` | The color shown: any HAM color (#C8553D, teal-500). | `#000000` |

## Readings

| Name | What it does |
|---|---|
| `brightness` | The brightness, 0–1. |
| `hue` | The hue, 0–360. |
| `recent` | The last recent= colors picked, newest first (a list of hex). |
| `saturation` | The saturation, 0–1. |
| `value` | The color picked, as #RRGGBB, live as the finger moves. |

Any tag also takes gestures: `@on.tap`, `@on.longpress`, `@on.doubletap` and `@on.swipeleft` (and right, up and down). `@click` runs on a tap too.

## Related tags

- [`<column>`](https://hypeapps.dev/docs/reference/column.md): Stacks its children top to bottom, with a gap between them and an alignment across.
- [`<text>`](https://hypeapps.dev/docs/reference/text.md): A run of text; with @text it shows an expression that updates as its variables change.
- [`<button>`](https://hypeapps.dev/docs/reference/button.md): A tappable button that runs an action: a fetch, a navigation or a statement.
- [`<checkbox>`](https://hypeapps.dev/docs/reference/checkbox.md): A checkbox with a label; its state goes into a variable by name.
- [`<chip>`](https://hypeapps.dev/docs/reference/chip.md): A compact chip: a label, a filter that toggles, a single choice in a set, or an action.
- [`<data-cell>`](https://hypeapps.dev/docs/reference/data-cell.md): One cell of a data table row.
- [`<data-column>`](https://hypeapps.dev/docs/reference/data-column.md): A column heading of a data table.
- [`<data-row>`](https://hypeapps.dev/docs/reference/data-row.md): One row of a data table, holding a data cell for each column.

All tags: https://hypeapps.dev/docs/reference.md · The full reference: https://hypeapps.dev/llms.txt
