Posts Learn Components Snippets Categories Tags Tools About
/

How to add class attribute to the body tag in NuxtJs

Learn how to add class attribute to the body tag in NuxtJS

Created on Jul 17, 2021

13047 views

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.

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

)