# Themes and Dark Mode

- Human documentation: [https://docs.univer.ai/guides/fundamentals/ui/themes](https://docs.univer.ai/guides/fundamentals/ui/themes)

- Agent Markdown: [https://docs.univer.ai/guides/fundamentals/ui/themes.md](https://docs.univer.ai/guides/fundamentals/ui/themes.md)

- Requested language: `en-US`

- Content language: `en-US`

- Documentation version: `1.0.0-rc.0`

- Source: [fundamentals/ui/themes.mdx](https://github.com/dream-num/documentation/blob/dev/content/guides/fundamentals/ui/themes.mdx)

---

## Using Official Themes

`@univerjs/themes` exports `defaultTheme` (also available as `blueTheme`), `darkBlueTheme`, `greenTheme`, `orangeTheme`, `purpleTheme`, `redTheme`, and `yellowTheme`.

> [!NOTE]
> When no theme is specified, 
> 
> `defaultTheme`
> 
>  is used by default.

### Installing Theme Plugins

#### Preset Mode

In preset mode, themes can be imported from the `@univerjs/presets` package:

```typescript
// import { defaultTheme } from "@univerjs/presets";
import { yellowTheme } from '@univerjs/presets'

const { univer } = createUniver({
  theme: yellowTheme,
  // theme: defaultTheme,
})
```

#### Plugin Mode

In plugin mode, themes are provided by the `@univerjs/themes` package, which you need to install first.

#### npm

```bash
npm install @univerjs/themes
```

#### pnpm

```bash
pnpm add @univerjs/themes
```

#### yarn

```bash
yarn add @univerjs/themes
```

#### bun

```bash
bun add @univerjs/themes
```

```typescript
import { yellowTheme } from '@univerjs/themes'
// import { defaultTheme } from "@univerjs/themes";

const univer = new Univer({
  theme: yellowTheme,
  // theme: defaultTheme,
})
```

## Customizing Themes

You can customize themes by creating an object that conforms to the `Theme` interface. Refer to [this documentation](https://docs.univer.ai/reference/types/theme.md) to understand how the default theme variables are defined.

```typescript title="custom-theme.ts"
import type { Theme } from '@univerjs/presets'
// import type { Theme } from "@univerjs/themes";

export const customTheme: Theme = {
  white: '#FEFEFE',
  black: '#1C1C1C',
  primary: {
    50: '#F6F5FF',
    100: '#EDEBFE',
    200: '#DCD7FE',
    300: '#CABFFD',
    400: '#AC94FA',
    500: '#9061F9',
    600: '#7E3AF2',
    700: '#6C2BD9',
    800: '#5521B5',
    900: '#4A1D96',
  },
  // ...
}
```

```typescript
// Import your custom theme here
import { customTheme } from './custom-theme'

const univer = new Univer({
  theme: customTheme,
})
```

### Theme Customizer

Use the standalone theme customizer to edit Univer theme tokens, preview light and dark modes, and copy the generated Theme JSON.

- [Open Theme Customizer](/tools/theme-customizer)
  Tune palette tokens, loop colors, highlights, and export a custom theme.

## Dark Mode

Univer supports dark mode, which can be enabled by setting the `darkMode` property to `true`.

```typescript
new Univer({
  darkMode: true,
})
```

### Facade API

You can also dynamically toggle dark mode using the Facade API.

```typescript
import { darkBlueTheme } from '@univerjs/themes'

univerAPI.setTheme(darkBlueTheme)
const currentTheme = univerAPI.getCurrentTheme()
console.log(univerAPI.isDarkMode(), currentTheme)

univerAPI.toggleDarkMode(false)
```
