|
4 | 4 | [](https://www.npmjs.com/package/@angularui/theme)
|
5 | 5 | [](https://opensource.org/licenses/MIT)
|
6 | 6 |
|
7 |
| -Modern Theme Management for Angular - A lightweight, feature-rich theme library with automatic dark mode detection, SSR support, and zero configuration required. |
| 7 | +Modern Theme Management for Angular - A lightweight, feature-rich theme library with automatic dark mode detection, SSR-safe, and zero configuration required. |
8 | 8 |
|
9 | 9 | **🌐 [Live Demo](https://angularcafe.github.io/angularui-theme/)**
|
10 | 10 |
|
11 | 11 | ## 🌟 Features
|
12 | 12 |
|
13 | 13 | - **🎨 Automatic Theme Detection** - Supports light, dark, and system themes with OS preference detection
|
14 | 14 | - **⚡ Angular 20 Signals** - Built with modern Angular signals for optimal performance and reactivity
|
15 |
| -- **🖥️ SSR Compatible** - Works perfectly with Angular SSR and server-side rendering |
| 15 | +- **🖥️ SSR-safe** - No hydration mismatch, works with Angular SSR out of the box |
16 | 16 | - **🎯 Zero Configuration** - Works out of the box with sensible defaults
|
17 | 17 | - **🔧 Flexible Strategy** - Choose between class-based or attribute-based theming
|
18 | 18 | - **📦 Tiny Bundle** - Lightweight with no unnecessary dependencies
|
@@ -106,6 +106,13 @@ Add this **inline** script to your `index.html` `<head>`:
|
106 | 106 | ```
|
107 | 107 | **Why inline?** Angular does not provide a way to inject scripts into the HTML `<head>` at build time. For true FOUC prevention, the script must run immediately as the HTML is parsed—before any content is rendered. External scripts or Angular providers/services run too late to prevent a flash. This is why the script must be copied directly into your `index.html` head.
|
108 | 108 |
|
| 109 | +**Note:** This approach is SSR-safe: the initial HTML uses the default theme, and the correct theme is applied instantly on page load. |
| 110 | + |
| 111 | +#### FAQ: SSR, LocalStorage, and Theme Flash |
| 112 | +- The SSR HTML always uses the default theme, since user preferences are only available in the browser. |
| 113 | +- The inline script applies the correct theme instantly on page load, so users never see a flash of the wrong theme. |
| 114 | +- This is the standard, SSR-safe approach used by modern theme libraries (like next-themes). |
| 115 | + |
109 | 116 | ## Why @angularui/theme?
|
110 | 117 |
|
111 | 118 | - Native Angular integration: signals, DI, and standalone components
|
|
0 commit comments