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


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 ☕️


PostSrc Code Components

Collection of Tailwind CSS components for everyone to use. Browse all of the components that are right for your project.

View Components