2020-07-17 11:30:46 +00:00
# Theming Element
2017-01-18 17:05:13 +00:00
Themes are a very basic way of providing simple alternative look & feels to the
2020-07-17 11:30:46 +00:00
Element app via CSS & custom imagery.
2017-01-18 17:05:13 +00:00
2020-07-17 11:30:46 +00:00
To define a theme for Element:
2017-01-18 17:05:13 +00:00
1. Pick a name, e.g. `teal` . at time of writing we have `light` and `dark` .
2024-10-15 13:57:26 +00:00
2. Fork `res/themes/dark/css/dark.pcss` to be `teal.pcss`
3. Fork `res/themes/dark/css/_base.pcss` to be `_teal.pcss`
2022-07-15 13:53:21 +00:00
4. Override variables in `_teal.pcss` as desired. You may wish to delete ones
which don't differ from `_base.pcss` , to make it clear which are being
overridden. If every single colour is being changed (as per `_dark.pcss` )
2017-01-18 17:05:13 +00:00
then you might as well keep them all.
5. Add the theme to the list of entrypoints in webpack.config.js
2024-10-15 13:57:26 +00:00
6. Add the theme to the list of themes in theme.ts
2017-01-18 17:05:13 +00:00
7. Sit back and admire your handywork.
In future, the assets for a theme will probably be gathered together into a
2017-01-18 22:46:12 +00:00
single directory tree.
2019-11-20 15:40:44 +00:00
# Custom Themes
2019-11-20 17:27:25 +00:00
Themes derived from the built in themes may also be defined in settings.
2019-11-20 17:39:58 +00:00
To avoid name collisions, the internal name of a theme is
`custom-${theme.name}` . So if you want to set the custom theme below as the
default theme, you would use `default_theme: "custom-Electric Blue"` .
2019-11-20 15:40:44 +00:00
2024-02-13 05:03:57 +00:00
e.g. in config.json:
2019-11-20 15:40:44 +00:00
2024-10-31 10:54:46 +00:00
```json5
2022-03-18 16:12:44 +00:00
"setting_defaults": {
2019-11-20 15:40:44 +00:00
"custom_themes": [
{
"name": "Electric Blue",
"is_dark": false,
2020-06-24 12:55:57 +00:00
"fonts": {
"faces": [
{
"font-family": "Inter",
"src": [{"url": "/fonts/Inter.ttf", "format": "ttf"}]
}
],
"general": "Inter, sans",
2020-06-24 13:15:59 +00:00
"monospace": "'Courier New'"
2020-06-24 12:55:57 +00:00
},
2019-11-20 15:40:44 +00:00
"colors": {
"accent-color": "#3596fc",
"primary-color": "#368bd6",
"warning-color": "#ff4b55",
"sidebar-color": "#27303a",
"roomlist-background-color": "#f3f8fd",
"roomlist-text-color": "#2e2f32",
"roomlist-text-secondary-color": "#61708b",
"roomlist-highlights-color": "#ffffff",
"roomlist-separator-color": "#e3e8f0",
"timeline-background-color": "#ffffff",
"timeline-text-color": "#2e2f32",
"timeline-text-secondary-color": "#61708b",
2020-04-27 17:44:05 +00:00
"timeline-highlights-color": "#f3f8fd",
2024-10-31 10:54:46 +00:00
// These should both be 8 values long
"username-colors": ["#ff0000", /*...*/],
"avatar-background-colors": ["#cc0000", /*...*/]
2024-02-13 05:03:57 +00:00
},
"compound": {
"--cpd-color-icon-accent-tertiary": "var(--cpd-color-blue-800)",
"--cpd-color-text-action-accent": "var(--cpd-color-blue-900)"
2019-11-20 15:40:44 +00:00
}
}, {
"name": "Deep Purple",
"is_dark": true,
"colors": {
"accent-color": "#6503b3",
"primary-color": "#368bd6",
"warning-color": "#b30356",
"sidebar-color": "#15171B",
"roomlist-background-color": "#22262E",
"roomlist-text-color": "#A1B2D1",
"roomlist-text-secondary-color": "#EDF3FF",
"roomlist-highlights-color": "#343A46",
"roomlist-separator-color": "#a1b2d1",
"timeline-background-color": "#181b21",
"timeline-text-color": "#EDF3FF",
"timeline-text-secondary-color": "#A1B2D1",
"timeline-highlights-color": "#22262E"
}
}
]
}
```
2020-04-27 17:44:05 +00:00
2024-02-13 05:03:57 +00:00
`compound` may contain overrides for any [semantic design token ](https://compound.element.io/?path=/docs/tokens-semantic-colors--docs ) belonging to our design system. The above example shows how you might change the accent color to blue by setting the relevant semantic tokens to refer to blue [base tokens ](https://compound.element.io/?path=/docs/tokens-color-palettes--docs ).
2020-06-24 12:55:57 +00:00
All properties in `fonts` are optional, and will default to the standard Riot fonts.