---
title: Copy a colour for your code
project: TotalColor
version: Latest
section: guides
language: en
license: 
url: https://totaljs.es/docs/totalcolor/latest/guides/copy-a-colour/
updated: 2026-12-02T15:40:46.087Z
---

# Copy a colour for your code

> TotalColor writes a colour in thirteen formats at once, so you copy the one that your code, your style sheet or your design needs.

## Copy one

In **Written as**, press the line of the format. The bottom of the window says what was copied.

## The formats

This is `#9AD959` in each of them:

| Format | Text |
| --- | --- |
| **HEX** | `#9AD959` |
| **RGB** | `rgb(154 217 89)` |
| **RGB, commas** | `rgb(154, 217, 89)` |
| **HSL** | `hsl(90 63% 60%)` |
| **OKLCH** | `oklch(81.6% 0.172 131.3)` |
| **HSB** | `90° 59% 85%` |
| **SwiftUI** | `Color(red: 0.604, green: 0.851, blue: 0.349)` |
| **UIKit** | `UIColor(red: 0.604, green: 0.851, blue: 0.349, alpha: 1)` |
| **AppKit** | `NSColor(srgbRed: 0.604, green: 0.851, blue: 0.349, alpha: 1)` |
| **Compose, Flutter** | `Color(0xFF9AD959)` |
| **Android XML** | `#FF9AD959` |
| **.NET** | `Color.FromArgb(255, 154, 217, 89)` |
| **From 0 to 1** | `0.604, 0.851, 0.349` |

If none is what you need, [write your own](#write-your-own-format).

## A colour that is not solid

Every format but **HSB** also writes how solid the colour is. HEX gets two more digits at the end, and **RGB, commas** becomes `rgba(154, 217, 89, 0.5)`.

## Mark the format that you use

Press the bookmark at the end of a line to mark that format. The marked one has a tick, and it is what TotalColor copies:

- as soon as you [pick a colour](/totalcolor/latest/guides/pick-a-colour/), if **Copy the marked one as soon as a colour is picked** is on;
- when you pick [from any app](/totalcolor/latest/guides/from-any-app/);
- with ⌘⇧C on the Mac and Ctrl+Shift+C on Windows and Linux.

## Write your own format

1. At the end of **Written as**, press **Write it your own way…**
2. In **Written**, type the text as your code wants it, with words in braces where the numbers go. For example, `vec4({r1}, {g1}, {b1}, {a})` copies `vec4(0.604, 0.851, 0.349, 1)`.
3. Look at **Gives**, below the field: it has the colour of now in your format. Press **Keep it**.

Your format is now the last line of **Written as**, called **Yours**. You copy it and mark it as any other.

| Words | What they become |
| --- | --- |
| `{r}` `{g}` `{b}` | Red, green and blue from 0 to 255 |
| `{r1}` `{g1}` `{b1}` | The same from 0 to 1 |
| `{a}` | How solid, from 0 to 1 |
| `{a255}` | How solid, from 0 to 255 |
| `{hex}` `{HEX}` | Six digits, small or capital, without `#` |
| `{hexa}` `{HEXA}` | Eight digits, with how solid at the end |
| `{h}` `{s}` `{l}` | Hue in degrees, strength and lightness in percent |

The braces of your code stay as they are: `{ r: {r} }` copies `{ r: 154 }`.

Press **Change your own way…** to write another. To have none, empty the field and press **Keep it**. If it was the marked format, HEX is marked again.
