Skip to content

Commit

Permalink
docs: add more descriptive multiple themes example
Browse files Browse the repository at this point in the history
lint: Use linter on md file
  • Loading branch information
Serpentarius13 committed Nov 1, 2024
1 parent c08a332 commit 9fc3d06
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions docs/guide/dual-themes.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,27 @@ const code = await codeToHtml('console.log("hello")', {
})
```

A token would be generated like:
`span` tokens would be generated with respective theme's css variables:

```html
<span style="color:#1976D2;--shiki-dark:#D8DEE9;--shiki-dim:#566575">console</span>
```

Then update your CSS snippet to control when each theme takes effect. Here is an example:
After that, you need to apply theme's css variables on element with `shiki` class and tokens under it, for example, based on parent's `data-theme` property:

```css
[data-theme='dark'] .shiki,
[data-theme='dark'] .shiki span {
background-color: var(--s-dark-bg) !important;
color: var(--s-dark) !important;
}

[data-theme='dim'] .shiki,
[data-theme='dim'] .shiki span {
background-color: var(--s-dim-bg) !important;
color: var(--s-dim) !important;
}
```

[Demo preview](https://htmlpreview.github.io/?https://raw.githubusercontent.com/shikijs/shiki/main/packages/shiki/test/out/multiple-themes.html)

Expand Down

0 comments on commit 9fc3d06

Please sign in to comment.