Themes and localization

Align editor appearance, dark mode, and language resources with your application.

Themes and internationalization are shared runtime capabilities. All six products use the same theme service, locale resources, and regional configuration, and custom plugins can observe the same state. Brand appearance and user preferences can change at runtime while content keeps its own data and styles.

The SDK provides 19 built-in interface language/region options and 7 theme palettes. All six products share appearance, locale, and region configuration; custom themes and application translations use the same services.

One state model for UI and rendering

ThemeService holds the complete palette and dark-mode state separately, publishing changes through currentTheme$ and darkMode$. UI expands the palette into --univer-* CSS variables and responds to the univer-dark class. Renderers observe the same service and mark affected components for repaint. The Canvas color service resolves tokens, maps colors for dark display, and caches those results.

The configuration and examples in this chapter target @univerjs/* and @univerjs-pro/* 1.2.0. Keep SDK dependency versions aligned in your application.

SettingOptions and scopeRuntime API
theme7 built-in palettes or a complete custom Theme.setTheme()
darkModetrue / false, default false; independent of the palette.toggleDarkMode()
locale19 built-in LocaleType values; load matching resources first.setLocale()
localesCombine product, feature, and application resources by locale identifier.loadLocales()
regionThe same LocaleType values; follows UI locale until explicitly set.setRegion()
directionltr / rtl, default ltr; menus and similar UI only. Canvas content does not yet support RTL.setDirection()
100%

Build a brand theme from a complete palette

@univerjs/themes provides primary, gray, functional color scales, loop-color, and highlight.background. Copy a built-in theme and replace the required branches while preserving the complete structure. setTheme() replaces a complete theme; it does not deep-fill a partial object. This example supplies a coherent violet brand scale.

The 7 built-in palettes are: blueTheme, darkBlueTheme, greenTheme, orangeTheme, purpleTheme, redTheme, yellowTheme.

defaultTheme is an alias of blueTheme. Select the palette and dark-mode state separately. The configurable branches include:

Theme branchConfigurable options
primary10 brand steps: 50, then 100 through 900.
gray12 neutral steps: 0, 50, 100 through 900, and 1000.
blue · red · orange · yellow · green · jiqing · indigo · purple · pink9 functional scales, with 10 steps each.
loop-color12 rotating color positions referencing palette tokens.
highlight.background16 background highlight positions, each with color and alpha.
TypeScript
import type { Theme } from '@univerjs/themes';import { defaultTheme } from '@univerjs/themes';export const brandTheme: Theme = {  ...defaultTheme,  primary: {    ...defaultTheme.primary,    50: '#F5F3FF', 100: '#EDE9FE', 200: '#DDD6FE', 300: '#C4B5FD',    400: '#A78BFA', 500: '#8B5CF6', 600: '#7C3AED', 700: '#6D28D9',    800: '#5B21B6', 900: '#4C1D95',  },};

Pass the theme into your selected product integration. This example uses the Sheet core preset and registers application-owned translation keys; other products use their own plugin composition.

TypeScript
import { LocaleType, mergeLocales } from '@univerjs/core';import { UniverSheetsCorePreset } from '@univerjs/preset-sheets-core';import SheetsCoreEnUS from '@univerjs/preset-sheets-core/locales/en-US';import { createUniver } from '@univerjs/presets';import { brandTheme } from './brand-theme';import '@univerjs/preset-sheets-core/lib/index.css';export const { univer, univerAPI } = createUniver({  theme: brandTheme,  darkMode: false,  locale: LocaleType.EN_US,  locales: {    [LocaleType.EN_US]: mergeLocales(SheetsCoreEnUS, {      'sales-report': { generate: 'Generate report', ready: 'Ready for {0}' },    }),  },  presets: [UniverSheetsCorePreset({ container: 'app' })],});

Change appearance at runtime and follow preferences

setTheme() changes the palette; toggleDarkMode() changes dark mode. Read them with getCurrentTheme() and isDarkMode(). Selecting darkBlueTheme alone does not enable the dark-mode flag. Appearance updates do not require destroying and recreating the editor.

This function follows the system preference and returns a cleanup function. If your application offers a manual appearance setting, call toggleDarkMode() from that setting’s handler instead.

TypeScript
import type { FUniver } from '@univerjs/core/facade';import { brandTheme } from './brand-theme';export function followSystemAppearance(univerAPI: FUniver): () => void {  univerAPI.setTheme(brandTheme);  const preference = window.matchMedia('(prefers-color-scheme: dark)');  const update = () => univerAPI.toggleDarkMode(preference.matches);  update();  preference.addEventListener('change', update);  return () => preference.removeEventListener('change', update);}

Call the function after editor setup and run its cleanup when the component unmounts or stops following the system. Retain the existing instance in React and similar integrations and update it through Facade.

Make custom plugins follow theme and language

Custom DOM uses the injected CSS variables and supplies styles for the dark class. Variables hold palette values; component styles still need to consume the dark-mode state.

CSS
.report-panel {  color: var(--univer-gray-900);  background: var(--univer-gray-0);  border: 1px solid var(--univer-gray-200);}.univer-dark .report-panel {  color: var(--univer-gray-100);  background: var(--univer-gray-800);  border-color: var(--univer-gray-700);}

Canvas extensions read live tokens through ThemeService, then obtain actual drawing colors through ICanvasColorService. This example combines theme, dark-mode, and locale changes into observable state. It translates labels and resolves colors when state changes, avoiding repeated lookup and allocation on every drawing frame.

TypeScript
import { Disposable, Inject, LocaleService, ThemeService, toDisposable } from '@univerjs/core';import { ICanvasColorService } from '@univerjs/engine-render';import { combineLatest, ReplaySubject } from 'rxjs';export interface IReportAppearance {  label: string;  accent: string;}export class ReportAppearance extends Disposable {  readonly state$ = new ReplaySubject<IReportAppearance>(1);  constructor(    @Inject(ThemeService) theme: ThemeService,    @Inject(LocaleService) locale: LocaleService,    @ICanvasColorService colors: ICanvasColorService,  ) {    super();    this.disposeWithMe(toDisposable(() => this.state$.complete()));    this.disposeWithMe(combineLatest([      theme.currentTheme$, theme.darkMode$, locale.currentLocale$,    ]).subscribe(() => {      this.state$.next({        label: locale.t('sales-report.generate'),        accent: colors.getRenderColor(theme.getColorFromTheme('primary.600')),      });    }));  }}

Register and resolve ReportAppearance through DI in your plugin. The view or drawing controller subscribes to state$ and refreshes; the consumer owns its subscription, and the service owner calls dispose(). Node.js also has theme and locale services but does not inject browser CSS.

Dark mode

Sheet, Doc, Slide, Relational Table, Canvases, and PDF all use the shared theme and dark mode. These are real screenshots from the local standard demos, with English UI and content. Dark display does not write mapped display colors back into the Snapshot; application appearance and PDF page processing are separate; the local PDF verification result is noted below.

ProductShared themeDark modeInterface i18n
Sheet✓✓✓
Doc✓✓✓
Slide✓✓✓
Relational Table✓✓✓
Canvases✓✓✓
PDF✓UI supported; content display issue✓

Language coverage depends on the resource bundles supplied by the selected products and installed features. An application palette does not register products, load locales, or import stylesheets.

19 built-in language and region options

LocaleType provides the following 19 options, including Simplified, Traditional, and Hong Kong Traditional Chinese variants. The main UI packages for all six products provide these resources; coverage of extensions depends on the selected package. Use bundle tags in import paths and the corresponding enum values for initialization and Facade configuration.

RTL scope: Arabic (ar-SA) and other locale bundles translate interface text such as menus and messages. direction: 'rtl' currently adapts menus and similar UI only. RTL layout and editing in the Canvas content area are not implemented yet.

Language (native name)Bundle tagConfiguration value
Englishen-USLocaleType.EN_US
简体中文zh-CNLocaleType.ZH_CN
繁體中文zh-TWLocaleType.ZH_TW
繁體中文(香港)zh-HKLocaleType.ZH_HK
日本語ja-JPLocaleType.JA_JP
한국어ko-KRLocaleType.KO_KR
Tiếng Việtvi-VNLocaleType.VI_VN
Bahasa Indonesiaid-IDLocaleType.ID_ID
Françaisfr-FRLocaleType.FR_FR
Deutschde-DELocaleType.DE_DE
Españoles-ESLocaleType.ES_ES
Catalàca-ESLocaleType.CA_ES
Italianoit-ITLocaleType.IT_IT
Português (Brasil)pt-BRLocaleType.PT_BR
Polskipl-PLLocaleType.PL_PL
Slovenčinask-SKLocaleType.SK_SK
Русскийru-RULocaleType.RU_RU
فارسیfa-IRLocaleType.FA_IR
العربيةar-SALocaleType.AR_SA

Internationalization across products: In the current 1.2.0 source, 92 modules in the Web SDK and Pro editors provide 1,751 locale entry files, covering shared UI, product editors, and features such as formulas, number formats, and comments. Resources are maintained and published by module; applications compose the enabled features and target locales.

This count covers locale entry .ts files under packages/*/src/locale in both source trees, excluding tests and generated subdirectories. It does not imply complete coverage of all 19 options in every module. Some modules include additional languages; LocaleType defines the common built-in options.

Compose locale resources by plugin, then load and select

LocaleService organizes resources by locale and resolves labels through namespaces and key paths. mergeLocales() combines product presets, feature plugins, and application translations. loadLocales() merges resources at runtime; setLocale() selects the language. Selecting a locale does not automatically download its bundle.

100%

This adds Chinese resources to the earlier Sheet instance, selects Chinese UI, and explicitly retains German regional conventions. LocaleType.ZH_CN has the value zhCN; zh-CN is the bundle filename or documentation-route form.

TypeScript
import type { FUniver } from '@univerjs/core/facade';import { LocaleType, mergeLocales } from '@univerjs/core';import SheetsCoreZhCN from '@univerjs/preset-sheets-core/locales/zh-CN';export function switchInterface(univerAPI: FUniver): void {  univerAPI.loadLocales(LocaleType.ZH_CN, mergeLocales(SheetsCoreZhCN, {    'sales-report': { generate: '生成报告', ready: '已为 {0} 就绪' },  }));  univerAPI.setLocale(LocaleType.ZH_CN);  univerAPI.setRegion(LocaleType.DE_DE);  univerAPI.setDirection('ltr');}

Keep keys such as sales-report.generate with their owning plugin. Use complete translated sentences and {0}, {1} placeholders for dynamic values, for example LocaleService.t('sales-report.ready', 'Alex'). Do not cache translations at module initialization. Once resources are initialized, a missing key currently falls back to the key itself. Interface switching does not translate content or rename existing Units.

Distinguish language, region, and content formatting

LayerActual effect
Interface localeMenus, messages, plugin labels, and some language-dependent behavior such as document segmentation.
regionParticipating currency actions, comment date/time display, and statistics formatting; no currency conversion or timestamp changes.
Content number formatsSaved Sheet number/date formats follow cell formats and their applicable content locale; changing region does not rewrite them all.
directionIndependent UI direction; changing language or region does not automatically switch it.

When no region is specified, the corresponding default applies. Once set explicitly, region can be selected independently of interface language. region is not a timezone setting. RTL currently adapts menus and similar UI only. Right-to-left layout and editing in the Canvas content area are not implemented yet.

Content themes and application themes have separate boundaries

The application theme controls the workbench and rendering defaults. It does not rewrite persisted cell fills, text, shapes, PDF annotations, or explicit Chart colors. Range/table themes, Slide color schemes, and Canvases content themes are managed through the corresponding public product capabilities.

Pro Charts have a separate IEchartTheme registry shared by Sheet, Doc, Slide, and Canvases Charts. An application Theme is not a Chart theme. In a host with the appropriate Chart plugins installed, import the Chart Facade and register a complete definition:

TypeScript
import type { IEchartTheme } from '@univerjs-pro/engine-chart';import type { FUniver } from '@univerjs/core/facade';import { UniverTheme1 } from '@univerjs-pro/engine-chart';import '@univerjs-pro/engine-chart/facade';export function registerBrandChartTheme(univerAPI: FUniver): void {  const chartTheme: IEchartTheme = {    ...UniverTheme1,    themeName: 'sales-brand',    theme: {      ...UniverTheme1.theme,      color: ['#7C3AED', '#0EA5E9', '#10B981', '#F59E0B'],    },  };  univerAPI.registerTheme('sales-brand', chartTheme);}

Select the registered name with the Chart builder’s setTheme('sales-brand'). An explicit Chart palette may override its series colors.

Keep appearance consistent within a browser document: current UI variables and the univer-dark class are written to the document root. Multiple editors should share one appearance or use separate documents such as iframes; separate containers alone do not isolate CSS themes.

Further reading: Themes and dark mode · Detailed i18n configuration · Plugins and Facade · Charts

Back to feature overview

How is this guide?

© 2026 DreamNum Co., Ltd.