Home / Snippets / How to add class attribute to the body tag in NuxtJs
How to add class attribute to the body tag in NuxtJs cover

How to add class attribute to the body tag in NuxtJs

13.2K

3 years ago

0 comments

To add the class attributes to the body tag in NuxtJs, you will have to define it inside the "nuxt.config.js" file. It's available under the "head.boddyAttrs.class" attribute and you can refer below.
# nuxt.config.js

export default {
  head: {
    bodyAttrs: {
      class: 'bg-gray-50'
    }
  }
  /* your other NuxtJS configs */
}

For more configs definitions you can refer to the Nuxt configuration file.
notion avatar

Alaz

Week-end developer currently experimenting with web, mobile, and all things programming.

Topics:

Frontend

Resource

Average

Average

Support Us

If you like our tutorial, support us by being our Patreon or buy us some coffee ☕️

Welcome to PostSrc V3

PostSrc Dark Logo

You have to login to favorite this