Skip to content

Commit 99e2fbe

Browse files
committed
refac: more docs
1 parent 50d7d41 commit 99e2fbe

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

docs/tutorials/theming.mdx

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ A theme is a single JSON object with the following properties. Only `id`, `name`
7575
| `animationScript` | `string` | A string of JavaScript code to be run in a web worker for custom canvas animations. |
7676
| `css` | `string` | A string of custom CSS rules to be injected. |
7777
| `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. |
7883
| `codeMirrorTheme` | `string` | The name of a [CodeMirror theme](https://codemirror.net/5/demo/theme.html) for the text editor. |
7984

8085
### Creating a Theme
@@ -86,6 +91,41 @@ The easiest way to start is using the built-in Theme Editor:
8691
3. Modify the properties. The editor provides a live preview as you make changes.
8792
4. Once you're happy, click **Save**.
8893

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).
98+
99+
```css
100+
@font-face {
101+
font-family: 'Roboto';
102+
src: url('https://fonts.gstatic.com/s/roboto/v30/KFOmCnqEu92Fr1Mu4mxK.woff2') format('woff2');
103+
}
104+
body, button, input, textarea {
105+
font-family: 'Roboto', sans-serif;
106+
}
107+
```
108+
109+
#### Controlling Features with Toggles
110+
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+
89129
### Example 1: Simple Color Theme
90130

91131
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.
164204
}
165205
```
166206

207+
### Example 5: Background Image Theme
208+
209+
This theme adds a background image to the chat and the overall system.
210+
211+
```json
212+
{
213+
"id": "galaxy-explorer",
214+
"name": "Galaxy Explorer",
215+
"base": "oled-dark",
216+
"emoji": "🚀",
217+
"systemBackgroundImageUrl": "https://example.com/path/to/galaxy.jpg",
218+
"systemBackgroundImageDarken": 0.5,
219+
"chatBackgroundImageUrl": "https://example.com/path/to/space.jpg",
220+
"chatBackgroundImageDarken": 0.3
221+
}
222+
```
223+
167224
### Sharing Your Theme
168225

169226
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

Comments
 (0)