Svelte styling
Svelte CSS styling patterns. Use for scoped styles, CSS custom properties, style: directive, :global, or styling child components.From its SKILL.md
npx -y skills add spences10/skills --skill svelte-stylingAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 15 stars15 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
1.9 KB, 419 tokens by cl100k_base, as published. Nobody here has run it
Svelte Styling
Quick Start
JS vars in CSS: Use style: directive to set CSS custom properties
from JavaScript.
<script>
let columns = $state(3);
</script>
<div style:--columns={columns}>
{@render children()}
</div>
<style>
div {
display: grid;
grid-template-columns: repeat(var(--columns), 1fr);
}
</style>
Styling Child Components
Preferred: Pass CSS custom properties as component props:
<!-- Parent.svelte -->
<Child --color="red" --spacing="1rem" />
<!-- Child.svelte -->
<h1>Hello</h1>
<style>
h1 {
color: var(--color, blue);
margin: var(--spacing, 0);
}
</style>
Fallback: Use :global when custom properties aren't possible
(e.g., library components):
<div>
<LibraryComponent />
</div>
<style>
div :global {
h1 { color: red; }
}
</style>
Reference Files
- styling-patterns.md - Complete CSS patterns and techniques
Notes
- All
<style>blocks are scoped to the component by default - Use
style:directive, not inline style strings, for dynamic values - Prefer CSS custom properties over
:globalfor child styling - Prefer class arrays/objects in
class={...}for conditional classes - Last verified: 2026-05-14
What ships with it: 1 file
2.8 KB alongside SKILL.md
references/
- styling-patterns.md2.8 KB