Using variables within style tag in Svelte

preview_player
Показать описание
📝 Using variables within style tag in Svelte

- using CSS Custom Properties
- using Svelte actions

🔗 Want to learn more from me? Check out these links:

#svelte
Рекомендации по теме
Комментарии
Автор

This is going to be so useful! I'm going to add this to my collection of helpers now.

JeffCaldwell-nemo_omen
Автор

Nice trick with the actions to automatically set the style variables!

PaulHobbs
Автор

At 0:04 useCssBariables is in a separate file. But after that you are using single file. 👍 Hope using action in other file can make it reusable action. Thanks for the tricky use of action 👍❤️❤️
... Compared to Vue, SVELTE looks more developer friendly 🔥🔥

SusanthCom
Автор

Good to know this trick.

Do you think Svelte will allow us to use JavaScript variables inside CSS style tags in the future?

maybepumpkins
Автор

Great video. I'm currently learning svelte and I'm trying to dynamically update body background colour using text from an input. Nothing seems to work. Thanks

Scipio-Nigerianus
Автор

Been banging my head on this issue, Li Hau, and could use your guidance.
I've got a store item/localVariable called heart. It's a boolean.

If heart is true, I want to add a class name "filled" to a div.
If untrue, add a class name "unfilled" to that save div.

My goal is that when a user comes to my site (or refreshes the page), Svelte will
fill in the proper class, depending on the state of that stored variable.

billpliske
Автор

Well, good to know... but this is so cumbersome it doesn't seem worth it in my case. I hope in the future Svelte can support JavaScript variables in its CSS, like it currently can for its HTML. Even if the underlying mechanism is the same - offloading that legwork to the framework would make this approach much more usable.

daviddrayton
Автор

Great video.

Can you make video about how svelte work under the hood more detail?? Thanks...

farhan_
join shbcf.ru