When working on a Svelte or Sveltekit project, there’s no way to directly add classes to the <body> or <svelte:body> tags. There’s an open issue on GitHub discussing this further, which includes a few workarounds from community members.
I found that for me, the easiest way to add custom classes was by using a global style selector.
For example, here’s an example showing how you could modify the background color of a page using Tailwind classes.
<style lang="postcss">
@reference "tailwindcss";
:global(body) {
@apply bg-neutral dark:bg-neutral-800;
}
</style>