---
name: "offThemeChange"
mode: "api"
versionRequirements:
  - { name: "Base Library", version: "2.10.0" }
title: "ty.offThemeChange"
---

## offThemeChange

> [VERSION] Base Library >= 2.10.0

### Description

Cancel listening to theme change events

### Parameters

`(callback: Function)`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `callback` | `(res: OnThemeChangeCallbackResult) => void` | Yes | Callback for canceling the theme change event listener |

### Return Value

None


### Referenced Types

##### `interface` OnThemeChangeCallbackResult

| Property | Type | Description |
| --- | --- | --- |
| `theme` | `"light" \| "dark"` | Current theme; valid values: light or dark |


### Examples

#### Stop listening for theme change events

```js
Page({
  data: {
    handler: null,
  },
  onLoad() {
    this.data.handler = (res) => {
      console.log('Current theme', res.theme);
    };
    ty.onThemeChange(this.data.handler);
  },
  onUnload() {
    ty.offThemeChange(this.data.handler);
  },
});
```
