I created a custom widget inside my module and I'm trying to figure out how to add css to widget template. I can do it with the styles tag inside my template (phtml) but I assume that is not the right way?
How should you add custom css / less code to your widget block?
asked Sep 17, 2018 at 14:12
Arno Vande Cappelle
6726 silver badges20 bronze badges
-
I think better to add it on a head blockfmsthird– fmsthird2019年03月28日 10:08:22 +00:00Commented Mar 28, 2019 at 10:08
-
although your css will be loaded in the frontend in general not when your widget is loaded onlyfmsthird– fmsthird2019年03月28日 10:11:42 +00:00Commented Mar 28, 2019 at 10:11
1 Answer 1
Within your custom widget module create the following file:
view/frontend/web/css/source/_extend.less
Add the following code to _extend.less:
@import 'widget/example.less';
Create your .less file here:
view/frontend/web/css/source/widget/example.less
answered Jan 23, 2021 at 18:21
Joshua34
2,3171 gold badge20 silver badges25 bronze badges
default