Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import css files in vue 3 child components?

I'm working on Vue 3, and I need to know how I can import different style sheets for different child components.

For example, I have 3 child components, let's say A and B, and I want to import style sheet X in A and style sheet Z in B.

like image 279
Hassaan Aslam Avatar asked Dec 06 '25 05:12

Hassaan Aslam


1 Answers

Importing CSS in Vue components

If you are setup and using webpack, you should be able to import css directly from inside <style> tags in component files.

// In Component A
<style scoped>
@import "./X.css"
</style>

// In Component B
<style scoped>
@import "./Y.css"
</style>

More info here:

  • https://cli.vuejs.org/guide/css.html
  • https://github.com/vuejs/vue-loader
like image 78
Phil Poore Avatar answered Dec 09 '25 00:12

Phil Poore