# JavaScript

Source: https://docs.interop.io/desktop/capabilities/windows/themes/javascript/index.html

## Overview

The Themes API is accessible via the [`io.themes`](https://docs.interop.io/desktop/reference/javascript/themes/api/index.md) object.

> ℹ️ *See the JavaScript [Themes example](https://github.com/InteropIO/js-examples/tree/master/themes) on GitHub.*

## Listing All Themes

To get a list of all available themes, use the [`list()`](https://docs.interop.io/desktop/reference/javascript/themes/api/index.md#API-list) method:

```javascript
const allThemes = await io.themes.list();
```

## Current Theme

To get the currently selected theme, use the [`getCurrent()`](https://docs.interop.io/desktop/reference/javascript/themes/api/index.md#API-getCurrent) method:

```javascript
const currentTheme = await io.themes.getCurrent();
```

## Selecting Themes

To select a theme, use the [`select()`](https://docs.interop.io/desktop/reference/javascript/themes/api/index.md#API-select) method:

```javascript
const themeName = "dark";

await io.themes.select(themeName);
```

## Events

To get notified when the theme changes, use the [`onChanged()`](https://docs.interop.io/desktop/reference/javascript/themes/api/index.md#API-onChanged) method:

```javascript
const handler = newTheme => console.log(newTheme.name);

io.themes.onChanged(handler);
```

## API Reference

For a complete list of the available Themes API methods and properties, see the [Themes API reference documentation](https://docs.interop.io/desktop/reference/javascript/themes/api/index.md).
