
Product
Announcing Precomputed Reachability Analysis in Socket
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
svelte-body
Advanced tools
Apply styles to the body in routes! Designed to work with Svelte Kit and Routify.
Apply styles to the body in routes! Designed to work with Svelte Kit and Routify.
Currently in Svelte Kit and Routify, applying styles per page to the body doesn't work. You can't use :global(body)
since the style tags aren't removed and reapplied on route change. svelte-body
handles that for you!
npm i svelte-body -D
# pnpm
pnpm add svelte-body -D
# yarn
yarn add svelte-body -D
Just like in regular html you can apply classes with class=""
and styles with style=""
.
<script>
import { Body } from 'svelte-body';
</script>
<Body class="some classes" style="color: blue" />
Alternativley you can use a style object like so:
<script>
import { Body } from 'svelte-body';
const style = {
backgroundColor: 'violet',
color: 'white',
'--cool-css-prop': '😎'
};
</script>
<Body {style} />
There are also svelte actions that can be used on <svelte:body />
:
classList
<script>
import { classList } from 'svelte-body';
</script>
<svelte:body use:classList={"red green blue"}>
style
<script>
import { style } from 'svelte-body';
</script>
<svelte:body use:style={"background-color: blue;"}>
It can also take an object:
<script>
import { style } from 'svelte-body';
</script>
<svelte:body
use:style="{{ backgroundColor: 'blue', '--cool-css-prop': '😎' }}"
/>
FAQs
Apply styles to the body in routes! Designed to work with Svelte Kit and Routify.
The npm package svelte-body receives a total of 1,216 weekly downloads. As such, svelte-body popularity was classified as popular.
We found that svelte-body demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
Product
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.
Product
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.