New Dec 25, 2025

Global styles are being overridden by Vant styles using Nuxt

Libraries, Frameworks, etc. All from Newest questions tagged vue.js - Stack Overflow View Global styles are being overridden by Vant styles using Nuxt on stackoverflow.com

I'm coding using Nuxt. I'm confused about the global styles import.

I using Vant(UI Library) and Sass in my project.

I've defined some simple styles in '/assets/styles/main.scss', like this:

/* /assets/styles/main.scss */
body {
  font-size: 14px;
  font-family: Arial, Helvetica, sans-serif;
}

And I use Vant's components in my pages(/pages/index.vue), like this:

<!-- /pages/index.vue -->
<template>
  <div>
    <van-button>Test</van-button>
  </div>
</template>

The button renders correctly, but the body's styles are being overridden by Vant's styles.

Screenshot of the body style

Because Vantā€˜s `base.css` that includes style settings for the `body` element, but my "main.scssā€œ is before ā€œbase.cssā€.

Screenshot of stylesheet

This is my nuxt configuration:

// nuxt.config.ts
export default defineNuxtConfig({
  modules: ["@vant/nuxt"],
  compatibilityDate: "2025-07-15",
  devtools: { enabled: true },
  css: ["@/assets/styles/main.scss"],
});

What I've tried:

// app.vue
<style lang="scss">
@use "~/assets/styles/main.scss";
</style>
// app.vue
<script setup lang="ts">
import "~/assets/styles/main.scss";
</script>
// nuxt.config.ts
export default defineNuxtConfig({
  modules: ["@vant/nuxt"],
  compatibilityDate: "2025-07-15",
  devtools: { enabled: true },
  vite: {
    css: {
      preprocessorOptions: {
        scss: {
          additionalData: `@use "~/assets/styles/main.scss" as *;`,
        },
      },
    },
  },
});

None of the above worked. I don't know how to make main.scss load after Vant's base.css. This way, my styles will have higher priority. Does anyone have any suggestions? Helpppppppppp

Scroll to top