---
url: /api/packages/core/src/functions/applyModify.md
---
[pantoken-root](../../../../index.md) / [packages/core/src](../index.md) / applyModify

# Function: applyModify()

> **applyModify**(`value`, `modify`): `string` | `undefined`

Beta

Apply a Tokens Studio [TokenModify](../interfaces/TokenModify.md) to a concrete hex colour.

## Parameters

### value

`string`

### modify

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

## Returns

`string` | `undefined`

The modified colour, or `undefined` when `value` is not a hex colour (so the caller
can fall back to preserving the modifier as metadata).

## Examples

**Darken, lighten, and add alpha**

```ts
import { applyModify } from "@pantoken/core";

applyModify("#808080", { type: "darken", value: 0.5, space: "hsl" });  // → "#404040"
applyModify("#808080", { type: "lighten", value: 0.5, space: "hsl" }); // → "#c0c0c0"
applyModify("#808080", { type: "lighten", value: 0.5, space: "lch" }); // → "#bdbdbd"
applyModify("#ffffff", { type: "alpha", value: 0.5, space: "hsl" });   // → "#ffffff80"
```

**Non-hex input returns undefined**

```ts
import { applyModify } from "@pantoken/core";

applyModify("var(--x)", { type: "darken", value: 0.1, space: "hsl" }); // → undefined
```
