#Astro Icon - Conditional Styling?
1 messages · Page 1 of 1 (latest)
The code you posted looks fine, if it does not work for you, you can post a full example. It all depends on how you manage theme variable though, as Astro icon runs on the server, so the server has to know it on build time for ssg, which does not makes sense, and runtime for ssr. What are you using ? ssg or ssr ?
Can I access variables from a script ? with the is:inline flag ?
That way I could use my var storedTheme to make the decission.
I am not using ssr for now.
A script tag can only use client side js variables. If you do not use ssr, then the variable you pass like that from an astro component is going to reset your theme on every page reload.
For more details about server vs client states management, see this https://stackoverflow.com/a/74840400/1324481