Skip to content
Back to skills

Svelte Styling

ASecurity

Svelte CSS styling patterns. Use for scoped styles, CSS custom properties, style: directive, :global, or styling child components.

  • 94 stars
  • 0 votes
  • 0 copies
  • 9 views
  • Added September 7, 2026
developmentjavascriptjava

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned September 7, 2026

npx -y skills add spences10/svelte-skills-kit --skill svelte-styling --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Svelte Styling?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Svelte Styling
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/spences10-svelte-styling/badge)](https://www.skillsdirectory.com/skills/spences10-svelte-styling)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: svelte-styling
# IMPORTANT: Keep description on ONE line for agent compatibility
# prettier-ignore
description: "Svelte CSS styling patterns. Use for scoped styles, CSS custom properties, style: directive, :global, or styling child components."
---

# Svelte Styling

## Quick Start

**JS vars in CSS:** Use `style:` directive to set CSS custom properties
from JavaScript.

```svelte
<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:

```svelte
<!-- 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):

```svelte
<div>
	<LibraryComponent />
</div>

<style>
	div :global {
		h1 { color: red; }
	}
</style>
```

## Reference Files

- [styling-patterns.md](references/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 `:global` for child styling
- **Last verified:** 2026-03-12

<!--
PROGRESSIVE DISCLOSURE GUIDELINES:
- Keep this file ~50 lines total (max ~150 lines)
- Use 1-2 code blocks only (recommend 1)
- Keep description <200 chars for Level 1 efficiency
- Move detailed docs to references/ for Level 3 loading
- This is Level 2 - quick reference ONLY, not a manual
-->

Files in this skill

  • SKILL.md1.7 KB
  • references/styling-patterns.md4.6 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.