You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/tutorials/theming.mdx
+57Lines changed: 57 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -75,6 +75,11 @@ A theme is a single JSON object with the following properties. Only `id`, `name`
75
75
|`animationScript`|`string`| A string of JavaScript code to be run in a web worker for custom canvas animations. |
76
76
|`css`|`string`| A string of custom CSS rules to be injected. |
77
77
|`sourceUrl`|`string`| A URL pointing to the raw `theme.json` file, allowing for automatic update checks. |
78
+
|`systemBackgroundImageUrl`|`string`| URL for an image to be used as the main background for the entire UI. |
79
+
|`systemBackgroundImageDarken`|`number`| A value from 0 to 1 to control the darkness of the system background image. |
80
+
|`chatBackgroundImageUrl`|`string`| URL for an image to be used as the background for the chat message area. |
81
+
|`chatBackgroundImageDarken`|`number`| A value from 0 to 1 to control the darkness of the chat background image. |
82
+
|`toggles`|`object`| An object to selectively enable or disable theme features. See the "Advanced Theming" section for details. |
78
83
|`codeMirrorTheme`|`string`| The name of a [CodeMirror theme](https://codemirror.net/5/demo/theme.html) for the text editor. |
79
84
80
85
### Creating a Theme
@@ -86,6 +91,41 @@ The easiest way to start is using the built-in Theme Editor:
86
91
3. Modify the properties. The editor provides a live preview as you make changes.
87
92
4. Once you're happy, click **Save**.
88
93
94
+
### Advanced Theming
95
+
96
+
#### Using Custom Fonts
97
+
You can embed custom fonts in your theme using the `css` property. By using the `@font-face` rule, you can load fonts from external services like Google Fonts. For best performance, you should link directly to the font file (e.g., a `.woff2` file).
The Theme Editor modal includes toggles for all major features (like gradients, custom CSS, animations, etc.). These toggles are always visible, allowing users to see the full range of customization options.
111
+
112
+
When you create a theme, you can define which of these features are active by default. For example, if you include a `gradient` object in your `theme.json`, the "Gradient" toggle will be enabled and switched on. If you omit the `gradient` property, the toggle will be switched off.
113
+
114
+
The `toggles` property in your `theme.json` gives you explicit control. By setting a feature's corresponding key to `true` or `false` in the `toggles` object, you can define its default on/off state in the editor. This is useful for creating themes with optional features that you want to be explicitly enabled or disabled by default.
115
+
116
+
Here are the available toggles:
117
+
118
+
-`cssVariables`
119
+
-`customCss`
120
+
-`animationScript`
121
+
-`tsParticles`
122
+
-`gradient`
123
+
-`systemBackgroundImage`
124
+
-`chatBackgroundImage`
125
+
126
+
### The Documentation Tab
127
+
The Theme Editor includes a "Documentation" tab, which is a valuable resource when creating themes. It contains a table of all available CSS variables with their default values and descriptions, as well as the full theme schema.
128
+
89
129
### Example 1: Simple Color Theme
90
130
91
131
This theme creates a "Forest" look by overriding the default CSS color variables.
@@ -164,6 +204,23 @@ For complete control, you can provide JavaScript for a custom canvas animation.
164
204
}
165
205
```
166
206
207
+
### Example 5: Background Image Theme
208
+
209
+
This theme adds a background image to the chat and the overall system.
To make your theme easily shareable and updatable, host the `theme.json` file somewhere with a raw file link (like GitHub Gist or a public repository) and set the `sourceUrl` property to that link. This allows others to install your theme with one click and receive updates automatically.
0 commit comments