--- name: devextreme-theming description: > Apply, customize, and switch DevExtreme themes (Generic, Material, Fluent) in Angular, React, Vue, jQuery, and ASP.NET Core Controls. Covers predefined theme CSS import, ThemeBuilder UI and CLI, SCSS variables, custom CSS overrides, color swatches, and runtime theme switching. Use when someone asks about theme setup, dark mode, light mode, theme switching, color swatches, applying a theme, changing colors/branding, or any scenario involving DevExtreme theming. Trigger phrases: "DevExtreme theme", "dark mode", "light mode", "theme switch", "theme switcher", "toggle theme", "color swatch", "generate a swatch", "apply a swatch", "ThemeBuilder", "custom theme", "brand colors", "runtime theme switching", "change theme at runtime". compatibility: DevExtreme 26.1+. Supports Angular 20+, React 18+, Vue 3, jQuery 3.x or 4.x, and ASP.NET Core Controls. metadata: author: DevExpress version: "26.1" --- # DevExtreme Theming Skill ## When to Use This Skill - Applying a predefined DevExtreme theme to a project. - Creating a custom theme with ThemeBuilder (UI or CLI). - Overriding theme styles with CSS classes or component `elementAttr`. - Implementing dark/light mode or runtime theme switching. - Using color swatches for mixed-theme layouts. - Setting up SCSS-based theme imports. --- ## Before You Start If the host agent has a structured question-asking tool available, use it to ask these questions one at a time with clear options — for example, Claude Code's `AskUserQuestion` tool or GitHub Copilot's `askQuestions` tool. If no such tool is available, ask the questions directly in the chat response before generating code. > ⚠️ **Always use DevExtreme theme CSS imports and `themes.current()` from `devextreme/ui/themes` for runtime switching. Never manually swap CSS classes on `document.body`, use Bootstrap, Ant Design, Material UI, or any other theming system. For scoped section overrides, use `.dx-swatch-*` wrapper classes — do not edit DevExtreme's internal CSS files directly.** 1. **Which framework?** Angular, React, Vue, jQuery, or ASP.NET Core Controls? 2. **Predefined theme or custom?** A stock Generic/Material/Fluent theme, or a custom palette/swatch built with ThemeBuilder? 3. **Build-time CSS or runtime switching?** A single fixed theme (CSS import) vs. letting the user toggle themes/swatches while the app is running? Skip the framework question if the request or project already identifies the framework. If the reply leaves it unresolved, re-ask once with the list: Angular, React, Vue, jQuery, or ASP.NET Core Controls. If it remains unresolved, default to React + Vite + TypeScript and state that assumption. ## Architecture Overview ```text DevExtreme Theme Pipeline ────────────────────────────────────────────────────────────────── Option A │ Import prebuilt CSS → dx.[theme].css Option B │ SCSS import → devextreme/scss/bundles/dx.[theme].scss Option C │ ThemeBuilder UI/CLI → export dx.[base].[color].css ────────────────────────────────────────────────────────────────── Runtime │ DevExpress.ui.themes.current(name) — same theme family Swatch │ .dx-swatch-xxx wrapper class — section-level overrides CSS API │ .dx-* classes / elementAttr / wrapperAttr — component-level ``` --- ## Theme Families | Family | Base name pattern | Notes | |---|---|---| | Generic | `generic.light`, `generic.dark`, `generic.contrast`, `generic.carmine`, etc. | Also compact variants: `generic.light.compact` | | Material Design | `material.blue.light`, `material.blue.dark`, `material.teal.light`, etc. | Color + mode segments | | Fluent | `fluent.blue.light`, `fluent.blue.dark`, etc. | Requires icon archive when exporting | **CSS file name pattern:** `dx.[theme-family].[color-variant].css` Examples: `dx.light.css`, `dx.dark.css`, `dx.material.blue.light.css`, `dx.fluent.blue.light.css` > Compact themes reduce all component sizes. Use these instead of `zoom`/`transform` CSS — DevExtreme does not support those properties. --- ## Documentation Reference | Topic | Reference File | |---|---| | Predefined themes — applying and CSS file names | [references/predefined-themes.md](references/predefined-themes.md) | | ThemeBuilder UI and CLI — creating custom themes | [references/themebuilder.md](references/themebuilder.md) | | Custom CSS overrides — classes, elementAttr, defaultOptions | [references/custom-css.md](references/custom-css.md) | | Runtime theme switching and color swatches | [references/runtime-switching.md](references/runtime-switching.md) | | Icons — built-in library, custom icons, external libraries, Fluent archive setup | [references/icons.md](references/icons.md) | --- ## Quick-Start: Apply a Theme ### React / Vue (Vite) ```ts // main.ts or main.tsx — import exactly ONE theme import 'devextreme/dist/css/dx.fluent.blue.light.css'; ``` ### Angular ```ts // angular.json — add to "styles" array "styles": [ "node_modules/devextreme/dist/css/dx.fluent.blue.light.css", "src/styles.css" ] ``` ### jQuery ```html ``` ### ASP.NET Core Controls ```cshtml ``` > Only one prebuilt theme should be active at a time. For runtime switching, see [references/runtime-switching.md](references/runtime-switching.md). --- ## Key API | API | Description | |---|---| | `DevExpress.ui.themes.current()` | Returns the currently active theme name | | `DevExpress.ui.themes.current(name)` | Switches to another theme in the same family (no page reload) | | `DevExpress.ui.themes.ready(callback)` | Fires after a theme finishes loading | | `elementAttr` | Adds CSS classes or attributes to a component's root element | | `wrapperAttr` | Adds CSS classes to a popup/overlay wrapper element (Popup, Tooltip, etc.) | | `defaultOptions(rule)` | Sets default options for all instances of a component type | --- ## Framework Rules Apply the conventions for the framework selected by the developer. ### Angular - Use standalone components and import the component-specific standalone DevExtreme exports unless the developer explicitly uses NgModules. - When supporting an older DevExtreme release without standalone exports, use that release's documented NgModule integration. - For nested configuration, use the most specific component export available (for example, a component-specific pager or item) instead of assuming a generic `Dxo*` or `Dxi*` export. - Prefer the component's aggregated event/types export, such as `DxDateBoxTypes`, when the package exposes one. ### React - Use function components and hooks. Generate TypeScript unless the developer requests JavaScript, and avoid `any` when a concrete DevExtreme type exists. - Prefer the component's aggregated types export, such as `DateBoxTypes`. - For a new React application, reuse the developer's tool or framework choice; ask only if it is unresolved. Recommend Vite when they have no preference; do not scaffold deprecated Create React App unless explicitly requested. ### Vue - Use Vue 3 with the Composition API and `