bodyAttributes

Type: object | (pageContext) => object
Kind: global.
Environment: server.

Implemented by: vike-react/vike-vue/vike-solid.

You need vike-react/vike-vue/vike-solid to be able to use this setting.

The bodyAttributes setting adds attributes to the <body> tag.

// pages/+config.js
 
export default {
  // <body class="dark">
  bodyAttributes: { class: 'dark' }
}

Global

This setting is global: its value always applies to all your pages. In other words, it doesn't support config inheritance.

You cannot set it at pages/some-page/+config.js: you have to set it at pages/+config.js (or some other global location) instead.

If you want to set different values for different pages, then consider creating a custom setting as shown at Guides > <head> tags > Custom settings.

See also