A
A
Alexey Nikolaev2021-09-24 20:52:11
Vue.js
Alexey Nikolaev, 2021-09-24 20:52:11

What is the best way to manage styles in Vue?

Good evening.
I'm primarily concerned with the following two approaches:
- the css per component approach, when the css is in the component
- css modules, when the css is imported from external files

Which one is objectively better? Does the first approach have any downsides? Is it worth it, in the first approach, to strive to keep css only in those components for which it is intended?

Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2021-09-24
@Aleksandr-JS-Developer

The only negative that can be in the first paragraph is the size of the .vue file
Of course, not in bytes, but in lines. It's hard to maintain 2000 lines of css code.
But, if you approach the construction of architecture correctly, then such situations can be avoided.
Except when you need to make a lot of changes in media queries. Then you can already include several files via @imort that are responsible for a specific media query.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question