Svelte · Junior · Question 35 of 76

How can a parent style an element inside a child component without breaking scoping?

<!-- Parent.svelte -->
<Child --accent="tomato" />

Explanation

Custom properties keep the child in control of its styles. :global is a fallback for third-party components.

Further reading

Problem with a question

Svelte · Junior · question 35

Test yourself

Take the Svelte · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz