Skip to content

Dyamic Styles #4355

@dm-de

Description

@dm-de

This is a short example (this do not work in svelte)

<script>
	export var color = '#000'
</script>

<style>
	button {
		background-color: {color}
	}
</style>

<button><slot/></button>

What if...
svelte compiler could detect a style with {color}
and remove this from generated STATIC css
But instead this lines goes to a DYNAMIC css class

Here some js ideas:
https://stackoverflow.com/questions/1720320/how-to-dynamically-create-css-class-in-javascript-and-apply

And when color value changes, we could update dynamic class

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions