Skip to content

Commit cddf545

Browse files
authored
Update 01-basic-markup.md
1 parent e40e9eb commit cddf545

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

documentation/docs/03-template-syntax/01-basic-markup.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,27 @@ As with elements, `name={name}` can be replaced with the `{name}` shorthand.
8282
<Widget foo={bar} answer={42} text="hello" />
8383
```
8484

85-
_Spread attributes_ allow many attributes or properties to be passed to an element or component at once.
85+
## Spreading
86+
87+
_Spreading_ allow many attributes or properties to be passed to an element or component at once.
8688

8789
An element or component can have multiple spread attributes, interspersed with regular ones.
8890

8991
```svelte
90-
<Widget {...things} />
92+
<button {...attributes}>...</button>
93+
<button {...attributes} type="button">...</button>
94+
<Widget {...props} />
95+
<Widget {...props} foo={bar} text="hello" {...aria} />
96+
```
97+
The order in which they are displayed matters
98+
99+
```svelte
100+
<script>
101+
const attributes = { type: "button" };
102+
</script>
103+
104+
<button {...attributes} type="submit">...</button> <!-- type is "submit" -->
105+
<button type="submit" {...attributes}>...</button> <!-- type is "button" -->
91106
```
92107

93108
## Events

0 commit comments

Comments
 (0)