-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #315 from element-hq/web-theming
Document the mechanism for theming Compound on Web
- Loading branch information
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Meta } from "@storybook/addon-docs"; | ||
|
||
<Meta title="Develop/Theming" /> | ||
|
||
# Theming | ||
|
||
The default set of design tokens provided by Compound contains some choices specific to Element's brand, which our users and customers may want to change to meet their needs. For this reason we allow Compound to be themed with custom sets of semantic tokens. | ||
|
||
## Web | ||
|
||
On Web, you can override any semantic token by redefining that token in the `custom` [cascade layer](https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Cascade_layers) provided by the [design tokens package](https://github.com/vector-im/compound-design-tokens/tree/develop/assets/web). This example demonstrates how you would change the `color.icon.accent-tertiary` token to blue, rather than Element's default green: | ||
|
||
```css | ||
@import "@vector-im/compound-design-tokens/assets/web/css/compound-design-tokens.css" layer(compound); | ||
|
||
@layer compound.custom { | ||
:root, [class*="cpd-theme-"] { | ||
--cpd-color-icon-accent-tertiary: var(--cpd-color-blue-800); | ||
} | ||
} | ||
``` | ||
|
||
As long as you use the provided layer, this ensures that future internal changes to the package will not cause conflicts in selector specificity. |