Skip to content
This repository was archived by the owner on Aug 5, 2025. It is now read-only.
This repository was archived by the owner on Aug 5, 2025. It is now read-only.

Basic Svelte / Classes and styles / Component styles: can't set the value on a parent div #658

Description

@VsevolodGolovanov

https://svelte.dev/tutorial/svelte/component-styles says:

Any parent element (such as <div class="boxes">) can set the value of --color, but we can also set it on individual components:

<div class="boxes">
	<Box --color="red" />
	<Box --color="green" />
	<Box --color="blue" />
</div>

This makes me think that I can do:

<div --color="red">

but this results in the error:

Error compiling App.svelte

'--color' is not a valid attribute name
https://svelte.dev/e/attribute_invalid_name

I think this could be explained clearer. Maybe show the way to set the value on a HTML tag first, and then introduce the component syntax?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions