--- title: Nested components --- As well as containing elements (and `if` blocks and `each` blocks), Svelte components can contain *other* Svelte components. ```html
``` ```htmlI am a nested component. The answer is {answer}
``` That's similar to doing this... ```js import Widget from './Widget.html'; const widget = new Widget({ target: document.querySelector('.widget-container'), props: { answer: 42 } }); ``` ...except that Svelte takes care of destroying the child component when the parent is destroyed, and keeps props in sync if they change. > Component names must be capitalised, following the widely-used JavaScript convention of capitalising constructor names. It's also an easy way to distinguish components from elements in your template. ### Props Props, short for 'properties', are the means by which you pass data down from a parent to a child component — in other words, they're just like attributes on an element. As with element attributes, prop values can contain any valid JavaScript expression. Often, the name of the property will be the same as the value, in which case we can use a shorthand: ```htmlThis is a box. It can contain anything.
the box is empty!