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

docs(examples): 📝 added multi-themes example #256

Merged
merged 10 commits into from
May 6, 2024

Conversation

lloydrichards
Copy link
Contributor

@lloydrichards lloydrichards commented Feb 17, 2024

Goals/Scope

I recently implemented next-theme on my own site with the desire to add multiple themes controlled through design tokens. I found that the examples and documentation were not very helpful when it came to structuring my project and so now that I've figured out what works, I want to be able to contribute a minimal example so others might save some time.

Description

For the example, I forked the with-app-dir example and added 6 themes to the global.css using css variables and then connected these variables to some color utilities in the tailwind.config.ts. Expanding on the page.ts with a <span> around the mutli to demo how the tailwind utility is used while keeping the rest using the normal text- and dark:text- to show that tailwind is still respecting the dark mode.

Screenshot 2024-02-17 at 21 18 50 Screenshot 2024-02-17 at 21 18 45 Screenshot 2024-02-17 at 21 18 40

Comments

I've not updated the README.md with an explanation on using multiple dark themes using the darkMode: ['class', '[data-theme^="dark-"]'], since I want to keep the scope of this PR narrow, but this might be nice to update too.

Copy link

vercel bot commented Feb 17, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
next-themes-basic ❌ Failed (Inspect) May 6, 2024 8:48am
next-themes-tailwind ❌ Failed (Inspect) May 6, 2024 8:48am
next-themes-with-app-dir ❌ Failed (Inspect) May 6, 2024 8:48am

@christian1koch
Copy link

I used this approach as well, seems to be the best way to create multiple color themes + light/dark themes.

Something I would have like tho, is to have light/dark themes separated from color themes, but that is only doable by having two different contexts, and since next-themes does not exposes the context, we can't do anything about it.

Copy link
Collaborator

@trm217 trm217 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks for your contribution @lloydrichards

@trm217
Copy link
Collaborator

trm217 commented Apr 22, 2024

@pacocoursey Should we also create a vercel deployment for this example?

@lloydrichards
Copy link
Contributor Author

@trm217 or @pacocoursey is there anything you need from me to get this merged? I agree that there should probably be some configuration with Vercel, but that's out of my hands I think.

Let me know as I have some time this week if need 👍

@trm217
Copy link
Collaborator

trm217 commented May 6, 2024

@lloydrichards No, all good, I was just waiting for paco to respond about the vercel deployment for the example. But I suppose we can also discuss that later.

@trm217 trm217 merged commit bf0c5a4 into pacocoursey:main May 6, 2024
3 of 6 checks passed
@lloydrichards lloydrichards deleted the example/multi-theme branch May 6, 2024 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants