4

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
2
  • I think better to add it on a head block Commented Mar 28, 2019 at 10:08
  • although your css will be loaded in the frontend in general not when your widget is loaded only Commented Mar 28, 2019 at 10:11

1 Answer 1

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

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.