20+ years web dev | Full-stack architect | AI integrator | Passionate about clean code, APIs, and docs | Building innovative SaaS with AI | Open source enthusiast
Yep - style props in Svelte are just syntactic sugar for setting CSS vars on a div. So <TextBox --line-color="mediumspringgreen"></TextBox> de-sugars into
20+ years web dev | Full-stack architect | AI integrator | Passionate about clean code, APIs, and docs | Building innovative SaaS with AI | Open source enthusiast
Do IDEs assist with that? For regular props its fairly easy since they are announced with export let foo; but how does it work for style props? Or do I need to assign them blindly?
For now, there's no way for component authors to specify which style props are available, aside from documentation. There's an open issue on the Svelte language tools (which makes IDE autocomplete work) to implement this feature.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Will the css variables get available in children further down the render tree?
Yep - style props in Svelte are just syntactic sugar for setting CSS vars on a div. So
<TextBox --line-color="mediumspringgreen"></TextBox>de-sugars intoSo the CSS vars will cascade to child elements like normal.
More details in the docs.
Thanks for the clarification!
Do IDEs assist with that? For regular props its fairly easy since they are announced with
export let foo;but how does it work for style props? Or do I need to assign them blindly?For now, there's no way for component authors to specify which style props are available, aside from documentation. There's an open issue on the Svelte language tools (which makes IDE autocomplete work) to implement this feature.