---
url: >-
  /api/plugins/pantoken/custom-theme-colors/src/functions/deriveCustomColorScale.md
---
[pantoken-root](../../../../../index.md) / [plugins/pantoken/custom-theme-colors/src](../index.md) / deriveCustomColorScale

# Function: deriveCustomColorScale()

> **deriveCustomColorScale**(`hex`, `tokens?`): [`CustomColorScale`](../interfaces/CustomColorScale.md)

Beta

Derive the `custom` primitive scale from a brand hex. The input is anchored at the step whose
reference lightness (the mean OKLCH lightness of the 13 shipped families) is nearest its own,
then every step is rebuilt at its reference lightness with the input's hue — so the anchor step
lands close to, but not necessarily exactly on, the input.

## Parameters

### hex

`string`

A `#rgb`/`#rrggbb` brand color.

### tokens?

readonly [`Token`](../../../../../packages/core/src/interfaces/Token.md)\[] | `Map`<`string`, `string`>

Optional token array or map to read the reference families from.

## Returns

[`CustomColorScale`](../interfaces/CustomColorScale.md)

The [CustomColorScale](../interfaces/CustomColorScale.md).

## Throws

TypeError when `hex` isn't a valid hex color.
