How to add a CSS class to the <body> tag via Svelte/SvelteKit?

Published

Option 1: Add styling to body

If you’re just looking to style the body of the page, then you can simply use the :global modifier:

In your __layout.svelte file, add styling for the body tag:

<style>
  :global(body) {
    background: AliceBlue;
  }
</style>

Option 2:

<svelte:head>
  <style>
    body {
      background: AliceBlue;
    }
  </style>
</svelte:head>

https://github.com/sveltejs/svelte/issues/3105 https://github.com/ghostdevv/svelte-body