---
name: "CanvasContext.setFillStyle"
mode: "api"
versionRequirements:
  - { name: "Base Library", version: "2.21.8" }
title: "setFillStyle"
---

## CanvasContext.setFillStyle

> [VERSION] Base Library >= 2.21.8

### Description

Set fill color

### Parameters

`Params`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `color` | `string \| CanvasGradient` | Yes | Fill color; supports 6-digit hex, rgb, rgba, color keywords (e.g., red), or a CanvasGradient object |

### Return Value

None


### Examples

#### Set fill color

```ts
const ctx = ty.createCanvasContext('myCanvas');
ctx.setFillStyle('#ff0000');
ctx.fillRect(10, 10, 150, 75);
ctx.draw();
```
