Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document the mechanism for theming Compound on Web #315

Merged
merged 1 commit into from
Feb 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions stories/develop/Theming.stories.mdx
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.
Loading