Syncfusion React Themes

syncfusion/react-ui-components-skills/skills/syncfusion-react-themes

作者 syncfusion6fb1c883a8412b611b95f839e0cb06e1fc8170a8無授權條款收錄於 2026年10月9日更新於 2026年10月9日

Use this skill when users need to apply themes, customize appearance, switch dark mode, use CSS variables, configure icons, or modify visual styling for Syncfusion React components. Covers icon library, size modes, and Theme Studio integration.

AI 產生的概覽

指導 Syncfusion React 元件的主題與視覺樣式設定,包括深色模式、CSS 變數、圖示和尺寸模式。

功能
此技能提供為 Syncfusion React 元件套用與自訂主題的說明。內容涵蓋內建主題套件、CDN 用法、從元件套件移轉至主題套件、深色模式、CSS 變數自訂、圖示庫、尺寸模式以及 Theme Studio。它產出設定指引與程式碼片段,而非產生檔案。
適用情境
當 React 專案使用 Syncfusion 元件,且需要套用主題、自訂外觀、切換深色模式、覆寫 CSS 變數、設定圖示或變更尺寸模式時使用。從元件套件移轉樣式至主題套件時也適用。
執行需求
需要一個 React 專案,並透過 npm 安裝 Syncfusion React 元件套件與主題套件,或使用版本相符的 CDN 樣式表。不隨附指令碼,僅為說明與參考文件。

Themes in Syncfusion React Components

Syncfusion React components provide comprehensive theming support with modern, customizable themes. This skill guides you through applying themes, customizing appearance, implementing dark mode, using CSS variables, managing icons, and creating custom themes for consistent, professional React applications.

Table of Contents

Documentation and Navigation Guide

Built-in Themes

📄 Read: references/built-in-themes.md [blocked]

  • Available 10+ themes
  • Applying themes via npm packages, CDN, or individual component styles
  • Optimized (lite) CSS files for reduced bundle size

Migrating Styles from Component Packages to Theme Packages

📄 Read: references/migration-styles.md [blocked]

  • Migrate from component packages to theme packages
  • SCSS & CSS Reference migration to theme packages
  • Automatic dependency inclusion via index files

Dark Mode Implementation

📄 Read: references/dark-mode.md [blocked]

  • Global dark mode with e-dark-mode class
  • Per-component dark mode
  • Runtime theme switching with checkboxes or toggle buttons

CSS Variables Customization

📄 Read: references/css-variables.md [blocked]

  • CSS variable structure for each theme (Material 3, Fluent 2, Bootstrap 5.3, Tailwind 3.4)
  • Customizing primary, success, warning, danger, info colors
  • Runtime color modification with JavaScript
  • Theme-specific variable formats (RGB vs hex values)

Icon Library

📄 Read: references/icons.md [blocked]

  • Setting up the icon library (npm or CDN)
  • Using icons with e-icons class
  • Icon sizing (small, medium, large)
  • Customizing icon color and appearance
  • Available icon sets per theme

Size Modes

📄 Read: references/advanced-theming.md [blocked]

  • Normal vs touch (bigger) size modes
  • Enabling size modes globally or per-component
  • Runtime size mode switching

Advanced Features

📄 Read: references/advanced-theming.md [blocked]

  • Styled-components integration
  • Font customization across all components
  • Theme Studio for custom theme creation

Quick Start

Install and Apply a Theme

Step 1: Install Syncfusion React Package and theme package

bash
npm install @syncfusion/ej2-react-buttons@latest @syncfusion/ej2-tailwind3-theme@latest --save

Step 2: Import Theme CSS

Option 1: Import from npm theme packages (Recommended)

css
/* src/App.css */@import "../node_modules/@syncfusion/ej2-tailwind3-theme/styles/button/index.css";

Option 2: Use CDN

⚠️ Important: The CDN version MUST match your installed npm package version to avoid style and rendering issues.

To find your installed version:

bash
npm list @syncfusion/ej2-react-buttons

Then use the matching CDN version:

html
<!-- index.html --><!-- Replace {VERSION} with your installed package version (e.g., 28.1.33, 33.1.44) --><link href="https://cdn.syncfusion.com/ej2/{VERSION}/tailwind3.css" rel="stylesheet"/>
<!-- Example: If your package version is 33.1.44 --><link href="https://cdn.syncfusion.com/ej2/33.1.44/tailwind3.css" rel="stylesheet"/>

Note: Using npm imports (Option 1) is recommended as it automatically keeps CSS and JavaScript versions in sync.

Common Patterns

Pattern 1: Apply Dark Mode Globally

typescript
import React, { useState } from 'react';import { CheckBoxComponent } from '@syncfusion/ej2-react-buttons';import { ButtonComponent } from '@syncfusion/ej2-react-buttons';
function App() {  const [isDarkMode, setIsDarkMode] = useState(false);
  const handleDarkModeToggle = (event) => {    const checked = event.checked ?? false;    setIsDarkMode(checked);        if (checked) {      document.body.classList.add('e-dark-mode');    } else {      document.body.classList.remove('e-dark-mode');    }  };
  return (    <div>      <CheckBoxComponent         label="Enable Dark Mode"         checked={isDarkMode}         change={handleDarkModeToggle}      />      <ButtonComponent cssClass="e-primary">Sample Button</ButtonComponent>    </div>  );}
export default App;

Pattern 2: Customize Primary Color with CSS Variables

For Fluent 2 Theme:

css
/* src/App.css */:root {  --color-sf-primary: #ff6b35;  /* Custom orange */}

For Material 3 Theme (uses RGB values):

css
/* src/App.css */:root {  --color-sf-primary: 255, 107, 53;  /* RGB: Custom orange */}

Pattern 3: Enable Touch Mode Globally

html
<!-- index.html --><body class="e-bigger">  <div id="root"></div></body>

Or per-component:

typescript
<ButtonComponent cssClass="e-bigger">Touch-Friendly Button</ButtonComponent>

Pattern 4: Use Optimized CSS for Faster Loading

css
/* src/App.css - Lite version without bigger mode styles */@import "@syncfusion/ej2-tailwind3-theme/styles/tailwind3-lite.css";

Pattern 5: Use Icons from Syncfusion Library

Install icons package:

You can install either the icons package or the theme package:

bash
npm install @syncfusion/ej2-icons@latest
/* or */
npm install @syncfusion/ej2-tailwind3-theme@latest

Import icon styles:

css
/* src/App.css *//* Syncfusion theme package icon styles */@import "../node_modules/@syncfusion/ej2-tailwind3-theme/styles/icons/tailwind3.css";
/* or */
/* Syncfusion components package icon styles */@import "../node_modules/@syncfusion/ej2-icons/styles/tailwind3.css";

Use icons in components:

typescript
<span className="e-icons e-cut"></span><span className="e-icons e-medium e-copy"></span><span className="e-icons e-large e-paste"></span>

來源與署名

來源:syncfusion/react-ui-components-skills位於skills/syncfusion-react-themes提交6fb1c88

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架