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

Temporarily changing the theme for certain pages #42

Closed
achadee opened this issue May 9, 2021 · 2 comments
Closed

Temporarily changing the theme for certain pages #42

achadee opened this issue May 9, 2021 · 2 comments

Comments

@achadee
Copy link

achadee commented May 9, 2021

Hi there, firstly, I love this project and thanks for working on it!

We have a few custom landing pages where the theme is dark. I was wondering if there was an option (or a way) to temporarily set the theme just for that page and not store the the new theme in localStorage. That way when the user visits another page, it doesn't carry across the theme.

Thanks

@pacocoursey
Copy link
Owner

Yep, that's exactly what the forcedTheme option does. Set a static property on your Page:

Page.theme = 'dark'

Then pass it along in your _app:

<ThemeProvider forcedTheme={Component.theme || undefined}>

It will set the theme for the page without modifying localStorage.

@achadee
Copy link
Author

achadee commented May 11, 2021

Beautiful! thank you so much, works a treat :)

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

No branches or pull requests

2 participants