Posts Learn Components new Snippets new Categories Tags 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

•

105 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.
new

If you like our tutorial, do make sure to support us with some coffee. We need the juice to write the content during the night 🤙🏻