Skip to content

[unocss support] How to configure dark mode with unocss? #1855

Answered by delucis
spokospace asked this question in Q&A
Discussion options

You must be logged in to vote

Starlight uses a data-theme attribute on the <html> element to indicate the current theme, i.e.

<html data-theme="dark">
<!-- or -->
<html data-theme="light">

I’ve never used UnoCSS, but based on their dark configuration reference, I think you should be able to configure it to use Starlight’s existing selectors:

presetMini({
  dark: {
    dark: '[data-theme="dark"]',
    light: '[data-theme="light"]',
  },
})

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by spokospace
Comment options

You must be logged in to vote
1 reply
@delucis
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants