---
url: /api/design/figma/src/functions/toFigmaColor.md
---
[pantoken-root](../../../../index.md) / [design/figma/src](../index.md) / toFigmaColor

# Function: toFigmaColor()

> **toFigmaColor**(`hex`): [`FigmaColor`](../interfaces/FigmaColor.md) | `undefined`

Experimental

Parse `#rgb`/`#rrggbb`/`#rrggbbaa` to a Figma RGBA (0–1), or `undefined` if not a hex colour.

## Parameters

### hex

`string`

## Returns

[`FigmaColor`](../interfaces/FigmaColor.md) | `undefined`

## Example

```ts
import { toFigmaColor } from "@pantoken/figma";

toFigmaColor("#ff0000"); // { r: 1, g: 0, b: 0, a: 1 }
toFigmaColor("not-a-color"); // undefined
```
