# Temas y modo oscuro

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

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

- Requested language: `es-ES`

- Content language: `es-ES`

- Documentation version: `1.2.0`

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

---

## Uso de Official Temas

`@univerjs/themes` exporta `defaultTheme` (también como `blueTheme`), `darkBlueTheme`, `greenTheme`, `orangeTheme`, `purpleTheme`, `redTheme` y `yellowTheme`.

> [!NOTE]
> Cuando no se especifica ningún tema, 
> 
> `defaultTheme`
> 
>  se utiliza de forma predeterminada.

### Instalación de complementos de tema

#### Modo preestablecido

En el modo preestablecido, los temas se pueden importar desde el paquete `@univerjs/presets`:

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

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

#### Modo complemento

En el modo complemento, los temas los proporciona el Paquete `@univerjs/themes`, que debe instalar primero.

#### 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,
})
```

## Personalizar temas

Puede personalizar temas creando un objeto que se ajuste a la interfaz `Theme`. Consulte [esta documentación ](https://docs.univer.ai/es-ES/reference/types/theme.md) para comprender cómo se definen las variables de tema predeterminadas.

```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,
})
```

### Personalizador de temas

Utilice el personalizador de temas independiente para editar tokens de temas de Univer, obtener una vista previa de los modos claro y oscuro y copiar el JSON del tema generado.

- [Open Theme Customizer](/tools/theme-customizer)
  Sintonice tokens de paleta, colores de bucle, resaltados y exporte un tema personalizado.

## Modo oscuro

Univer admite el modo oscuro, que puede ser habilitado configurando la propiedad `darkMode` en `true`.

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

### API de Facade

También puede alternar dinámicamente el modo oscuro usando la API de Facade.

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

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

univerAPI.toggleDarkMode(false)
```
