svelte-attr Svelte Themes

Svelte Attr

Library that dynamically changes the attributes of html and body tags with SvelteKit's SSR

svelte-attr

svelte-attr is a library that dynamically changes the attributes of html and body tags with SvelteKit's SSR.

Install

npm install svelte-attr

Usage

// src/hooks.server.ts

import type { Handle } from '@sveltejs/kit';
import { svelteAttr } from 'svelte-attr';

export const handle: Handle = async ({ event, resolve }) => {
    return svelteAttr(resolve(event));
};
<script lang="ts">
    import { HtmlAttr, BodyAttr } from 'svelte-attr';
</script>

<HtmlAttr lang="en" />
<BodyAttr data-theme="dark" />

Top categories

Loading Svelte Themes