The <style lang="scss"> or <style lang="sass"> in Vue

·

1 min read

As you may know, when working with Vue files, we typically include three sections: template, style, and script, for each component.

In the <style> section, you have the option to include the 'scoped' attribute, like this: <style scoped>. This attribute ensures that your styling code remains confined to the scope of that file only.

But, did you know you can also specify a 'lang' attribute within the <style> tag? This attribute is not used for changing languages like English to Spanish, but rather to indicate that you want to write your styles in a different preprocessor, such as SCSS or SASS. For example, you can use <style lang="scss"></style> or <style lang="sass"></style>.

The only thing you need beforehand is to have SASS installed in your Vue project.

If you don't know if it is installed, just give it a try and then start your server to see your project in action. If you encounter a warning, like Preprocessor dependency "sass" not found. Did you install it? Try pnpm add -D sass then just go to your terminal and run the suggested command. All should be then good and fine.