---
title: Color
description: Stores color data including opacity.
---

Stores color data including opacity.

A color can be created using a hex value, e.g. #FF0000 and optionally an alpha or it can be created using the provided system colors.

## Properties

### alpha

Alpha of the color.

```typescript
alpha: number
```

Read-only.

### blue

Amount of blue in the color.

```typescript
blue: number
```

Read-only.

### green

Amount of green in the color.

```typescript
green: number
```

Read-only.

### hex

HEX representation.

```typescript
hex: string
```

Read-only.

### red

Amount of red in the color.

```typescript
red: number
```

Read-only.

## Methods

<span id="-new-color" class="api-anchor"></span>

### new Color(hex, alpha)

Constructs a color.

```typescript
new Color(hex: string, alpha: number)
```

Constructs a new color with a hex value and optionally an alpha value. The hex value may specify the alpha value but this will be ignored if the alpha value parameter is provided. Examples of valid hex values: #ff0000, #00ff0080 
#00f and #ff. The hashtag is optional.

#### Parameters

**`hex` `string`**

Hex value.

**`alpha` `number`**

Alpha value.

### black()

Constructs a black color.

```typescript
static black(): Color
```

#### Return value

**`Color`**

A black color.

### blue()

Constructs a blue color.

```typescript
static blue(): Color
```

#### Return value

**`Color`**

A blue color.

### brown()

Constructs a brown color.

```typescript
static brown(): Color
```

#### Return value

**`Color`**

A brown color.

### clear()

Constructs a transparent color.

```typescript
static clear(): Color
```

#### Return value

**`Color`**

A transparent color.

### cyan()

Constructs a cyan color.

```typescript
static cyan(): Color
```

#### Return value

**`Color`**

A cyan color.

### darkGray()

Constructs a dark gray color.

```typescript
static darkGray(): Color
```

#### Return value

**`Color`**

A dark gray color.

<span id="dynamic" class="api-anchor"></span>

### dynamic(lightColor, darkColor)

Creates a dynamic color.

```typescript
static dynamic(lightColor: Color, darkColor: Color): Color
```

The dynamic color will use either its light or dark variant depending the appearance of the system.

`DrawContext` resolves the color when drawing in the app. The resulting image keeps that color when the appearance changes.

#### Parameters

**`lightColor` `Color`**

Color used in light appearance.

**`darkColor` `Color`**

Color used in dark appearance.

#### Return value

**`Color`**

Dynamic color.

### gray()

Constructs a gray color.

```typescript
static gray(): Color
```

#### Return value

**`Color`**

A gray color.

### green()

Constructs a green color.

```typescript
static green(): Color
```

#### Return value

**`Color`**

A green color.

### lightGray()

Constructs a light gray color.

```typescript
static lightGray(): Color
```

#### Return value

**`Color`**

A light gray color.

### magenta()

Constructs a magenta color.

```typescript
static magenta(): Color
```

#### Return value

**`Color`**

A magenta color.

### orange()

Constructs a orange color.

```typescript
static orange(): Color
```

#### Return value

**`Color`**

A orange color.

### purple()

Constructs a purple color.

```typescript
static purple(): Color
```

#### Return value

**`Color`**

A purple color.

### red()

Constructs a red color.

```typescript
static red(): Color
```

#### Return value

**`Color`**

A red color.

### white()

Constructs a white color.

```typescript
static white(): Color
```

#### Return value

**`Color`**

A white color.

### yellow()

Constructs a yellow color.

```typescript
static yellow(): Color
```

#### Return value

**`Color`**

A yellow color.