Skip to content

Inconsistent When Passing CSS Variables in Svelte #16599

@sunflower-knight

Description

@sunflower-knight

Describe the bug

I've defined a dynamically updating CSS variable --hue in App.svelte (updates every 50ms) and I'm passing it to Child components using four different methods:

Directly via Svelte's --bg-color property on the component tag
Via the style attribute setting --bg-color
Relying on CSS variable inheritance (parent defines variable, child uses it)
Referencing the parent variable in the style attribute with var(--parent-bg)

However, I've noticed that the colors displayed in the child components are inconsistent

Reproduction

https://svelte.dev/playground/5b8bf537ceb040ea9ece40788153d0a8?version=5.38.0

Logs

System Info

svelte playground + chrome

Severity

annoyance

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