Closed jkwchui closed 2 years ago
The Provider component includes a background corresponding to the theme you've provided. In this case, it looks like dark mode is active so you are seeing a dark gray background.
I suspect the CSS for spectrum is conflicting with Tailwind CSS in some way as well.
Thanks @devongovett for pointing out that this is by design. Is there a way to override the behaviour? I'm hoping to incrementally adopt Spectrum.
Provider has an UNSAFE_className prop. You could use that to override the background color potentially.
Oh I didn't see that. Thank you very much; I've slapped on a dirty fix while swapping out Tailwind.
<!-- in _app.js -->
<Provider theme={darkTheme} locale="en-US" UNSAFE_className="dark:bg-gray-900">
i'm facing this same issue & my font-size has also been reduced & different font is used just bcz i wrapped it in SSRProvider
& Provider
. i don't want all of that to change at all. how do i do it?
also, is there any way to use it without having to wrap it in SSRProvider
& Provider
or is it necessary with Next.js? my sentiment is like this comment right now?
From one of your other comments, I gather you are not using React Spectrum, but are instead using React-Aria to create your own components?
React Spectrum itself isn't meant to be super approachable with theming, not yet anyways. It's meant to enforce our design system. The hooks are there for you to make your own, giving you full control of all rendering. We have plans to eventually make the variable theming easier, but it's a low priority. For now, they are meant for making small changes when React Spectrum is already very close to what you want.
SSRProvider is necessary and will continue to be necessary because it makes ID's predictable across SSR and hydration. It'll be needed until we can take advantage of React 18's useId.
If you're only using our hooks to make your own components, I don't think you need the Provider though. I could be wrong on that, but the order of dependencies is stately->aria->react-spectrum. Nothing can go the other direction, so no aria package should depend on react-spectrum.
From one of your other comments, I gather you are not using React Spectrum, but are instead using React-Aria to create your own components?
i was still using spectrum, my mistake. i switched to aria to use my own combobox using tailwind like this example
removed Provider
& kept SSRProvider
& it worked fine, thanks :)
🐛 Bug Report
In a
next.js
setup of React Spectrum, where only the<Provider>
and<SSRProvider>
is wrapped around the app, no visual effect should be seen. However, a black (--spectrum-global-color-gray-100) background-color is applied over a<div>
that occupies the height of the viewport. The height of this div funkily depends on the initial viewport height.🤔 Expected Behavior
No visual change when only
Provider
/SSRProvider
are wrapped, and should remain as:😯 Current Behavior
A css class
is applied to the inner
<div>
through askin.css
when none is expected.
🔦 Context
The unintended visual artifact makes it not possible to use react-spectrum in the project.
💻 Code Sample
FWIW this is the
next.config.js
:🌍 Your Environment