You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Style not applied when using returned component #27
Nope, I am not using extractCss. The picture have shown all the code I have. I do not quite understand how to use it. So if I want to export the component. Do I need to export the CSS style separately?
Or in my case, which steps I have missed to successfully export the component?
Yeah with CSS in JS libraries you need to put the CSS on the page when you SSR. To be fair I have no clue how to do this with Astro. But generally you call extractCss after server rendering and then generate the Style tag like shown in the docs and insert it in the head of your page. I don't know how Astro handles these sort of injections. Might be worth asking them. But without it the CSS won't be present when the app renders. Now it is possible something else is going on as well since once the Solid component hydrates it should rerun some of this logic in the client.
I made a failed attempt here: https://stackblitz.com/edit/github-rqtizn-easxa3?file=astro.config.mjs. The integration does not work because document does not exist to inject css
Without the extractCss, it will work only when client:load is enabled for a component since the js will inject the css at runtime but no SSR stylesheet
Yeah all CSS in JS libraries generally work this way requiring a way to serialize it out with something like extractCss I'm just not clear what Astro does here. This seems like more of an Astro question. Yeah reading the issue most CSS in JS libraries aren't built to handle their case.
I was staring at the adapter API yesterday and thought that the one place that make sense is through: https://docs.astro.build/en/reference/integrations-reference/#injectscript-option but this obviously does not work because Astro does not have an API to add to <head />
I guess another solution is potentially using vite virtual module to call extractCss and let vite inject the css to the header.
This is all my noob research theory since I am very unfamiliar with both vite and astro.
But yeah i saw both twind and goober requires the extractCss pattern. I guess a framework like svelte/vue has the advantage in this particular scenario since they don't need css-in-js and can just handle SSR their css with addRenderer API. addRenderer is the on place I can see so far that you can put random text in the header
Activity
ryansolid commentedon Jun 1, 2022
Is the SSR script getting included on the page? Ie are you using
extractCss(https://github.com/solidjs/solid-styled-components#extractcsstarget)? CSS in JS library like this will need to output a style tag on the page. Otherwise not sure timing of when JS will be run.I'm pretty sure this works pure client-side. As for server-side I'm just guessing. A reproduction could help narrow this down.
BulliedBeginner commentedon Jun 1, 2022
Nope, I am not using extractCss. The picture have shown all the code I have. I do not quite understand how to use it. So if I want to export the component. Do I need to export the CSS style separately?
Or in my case, which steps I have missed to successfully export the component?
ryansolid commentedon Jun 1, 2022
Yeah with CSS in JS libraries you need to put the CSS on the page when you SSR. To be fair I have no clue how to do this with Astro. But generally you call
extractCssafter server rendering and then generate the Style tag like shown in the docs and insert it in the head of your page. I don't know how Astro handles these sort of injections. Might be worth asking them. But without it the CSS won't be present when the app renders. Now it is possible something else is going on as well since once the Solid component hydrates it should rerun some of this logic in the client.dephiros commentedon Sep 7, 2022
I made a failed attempt here: https://stackblitz.com/edit/github-rqtizn-easxa3?file=astro.config.mjs. The integration does not work because
documentdoes not exist to inject cssWithout the
extractCss, it will work only when client:load is enabled for a component since the js will inject the css at runtime but no SSR stylesheetryansolid commentedon Sep 8, 2022
Yeah all CSS in JS libraries generally work this way requiring a way to serialize it out with something like
extractCssI'm just not clear what Astro does here. This seems like more of an Astro question. Yeah reading the issue most CSS in JS libraries aren't built to handle their case.dephiros commentedon Sep 8, 2022
I was staring at the adapter API yesterday and thought that the one place that make sense is through: https://docs.astro.build/en/reference/integrations-reference/#injectscript-option but this obviously does not work because Astro does not have an API to add to
<head />I guess another solution is potentially using
vitevirtual module to callextractCssand letviteinject thecssto the header.This is all my noob research theory since I am very unfamiliar with both
viteandastro.But yeah i saw both twind and goober requires the
extractCsspattern. I guess a framework likesvelte/vuehas the advantage in this particular scenario since they don't need css-in-js and can just handle SSR their css withaddRendererAPI.addRendereris the on place I can see so far that you can put random text in the headermlaopane commentedon Dec 29, 2022
@BulliedBeginner
Don't you need to forward the props to a top level tag in your component ?
Also when creating an issue, I'd generally recommend to :
Otherwise, it makes it harder for people who may want to help.