Skip to content

Commit

Permalink
docs: add more descriptive multiple themes example
Browse files Browse the repository at this point in the history
  • Loading branch information
Serpentarius13 committed Nov 1, 2024
1 parent c08a332 commit 10ebf41
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions docs/guide/dual-themes.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,25 @@ 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 {

Check failure on line 109 in docs/guide/dual-themes.md

View workflow job for this annotation

GitHub Actions / lint

Replace `"dark"]·.shiki,·[data-theme="dark"` with `'dark']·.shiki,⏎[data-theme='dark'`
background-color: var(--s-dark-bg) !important;

Check failure on line 110 in docs/guide/dual-themes.md

View workflow job for this annotation

GitHub Actions / lint

Delete `··`
color: var(--s-dark) !important;

Check failure on line 111 in docs/guide/dual-themes.md

View workflow job for this annotation

GitHub Actions / lint

Delete `··`
}

[data-theme="dim"] .shiki, [data-theme="dim"] .shiki span {

Check failure on line 114 in docs/guide/dual-themes.md

View workflow job for this annotation

GitHub Actions / lint

Replace `"dim"]·.shiki,·[data-theme="dim"` with `'dim']·.shiki,⏎[data-theme='dim'`
background-color: var(--s-dim-bg) !important;

Check failure on line 115 in docs/guide/dual-themes.md

View workflow job for this annotation

GitHub Actions / lint

Delete `··`
color: var(--s-dim) !important;

Check failure on line 116 in docs/guide/dual-themes.md

View workflow job for this annotation

GitHub Actions / lint

Delete `··`
}
```

[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 10ebf41

Please sign in to comment.