diff --git a/site/content/docs/02-template-syntax.md b/site/content/docs/02-template-syntax.md index 29d28bfb3d..923616ccae 100644 --- a/site/content/docs/02-template-syntax.md +++ b/site/content/docs/02-template-syntax.md @@ -1236,6 +1236,74 @@ As with DOM events, if the `on:` directive is used without a value, the componen ``` +#### [--style-props](style_props) + +```sv +--style-props="anycssvalue" +``` + +--- + +As of [Svelte 3.38](https://github.com/sveltejs/svelte/issues/6268) ([RFC](https://github.com/sveltejs/rfcs/pull/13)), you can pass styles as props to components for the purposes of theming, using CSS custom properties. + +Svelte's implementation is essentially syntactic sugar for adding a wrapper element. This example: + +```sv + +``` + +--- + +Desugars to this: + +```sv +
+ +
+``` + +**Note**: Since this is an extra div, beware that your CSS structure might accidentally target this. Be mindful of this added wrapper element when using this feature. Also note that not all browsers support `display: contents`: https://caniuse.com/css-display-contents + +--- + +Svelte's CSS Variables support allows for easily themable components: + +```sv + + +``` + +--- + +So you can set a high level theme color: + +```css +/* global.css */ +html { + --theme-color: black; +} +``` + +--- + +Or override it at the consumer level: + +```sv + +``` #### [bind:*property*](bind_component_property)