Posts Learn Snippets 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

15 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.

Created by

PostSrc poster

PostSrc

Full stack developer mainly focusing on the front end side of the web. The main author of PostSrc and loves writing tutorial and guides online.