Skip to content
Coder Dad

Coder Dad

Menu
  • About me
  • How was it started?
Menu

How to add class attributes to the body tag in Nuxt?

Posted on December 30, 2021December 30, 2021 by coderdad

Nuxt has a great configuration file called nuxt.config.js. There are bunches of settings you can modify. There is a head section at the top. You can add body attributes such as class under the ‘bodyAttrs’ keyword like below:

// nuxt.config.js 

export default {
  // Global page headers: https://go.nuxtjs.dev/config-head
  head: {
    title: 'Kitapi',
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: '' },
      { name: 'format-detection', content: 'telephone=no' },
    ],
    link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }],
    // You can add any body attributes under bodyAttrs keyword
    bodyAttrs: {
      class: 'hebe'    
    },    
  },

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Archives

  • February 2022
  • January 2022
  • December 2021
  • December 2019
  • March 2019
  • February 2019
  • January 2019

Categories

  • General
  • Javascript
  • Learning English
  • macOs
  • Swift
  • Vue

  • BT Magazin (Technology)
  • Kadin & Sanat (Woman, food & art)
  • Gezentigiller (Traveling)
  • BT Hayat (IT & Life)
  • Okul Akademi (Educational)
©2022 Coder Dad | Built using WordPress and Responsive Blogily theme by Superb