Skip to content

Commit 8fc8bc7

Browse files
7nik7nikRich-Harris
authored
docs: add missing bindings (#15834)
* add missing bindings docs * tweak * tweak --------- Co-authored-by: 7nik <[email protected]> Co-authored-by: Rich Harris <[email protected]>
1 parent b6fe1cc commit 8fc8bc7

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

documentation/docs/03-template-syntax/11-bind.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,29 @@ Since 5.6.0, if an `<input>` has a `defaultChecked` attribute and is part of a f
117117
</form>
118118
```
119119

120+
## `<input bind:indeterminate>`
121+
122+
Checkboxes can be in an [indeterminate](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/indeterminate) state, independently of whether they are checked or unchecked:
123+
124+
```svelte
125+
<script>
126+
let checked = $state(false);
127+
let indeterminate = $state(true);
128+
</script>
129+
130+
<form>
131+
<input type="checkbox" bind:checked bind:indeterminate>
132+
133+
{#if indeterminate}
134+
waiting...
135+
{:else if checked}
136+
checked
137+
{:else}
138+
unchecked
139+
{/if}
140+
</form>
141+
```
142+
120143
## `<input bind:group>`
121144

122145
Inputs that work together can use `bind:group`.
@@ -227,6 +250,7 @@ You can give the `<select>` a default value by adding a `selected` attribute to
227250
- [`seeking`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/seeking_event)
228251
- [`ended`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/ended)
229252
- [`readyState`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/readyState)
253+
- [`played`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/played)
230254

231255
```svelte
232256
<audio src={clip} bind:duration bind:currentTime bind:paused></audio>
@@ -254,6 +278,10 @@ You can give the `<select>` a default value by adding a `selected` attribute to
254278
</details>
255279
```
256280

281+
## `window` and `document`
282+
283+
To bind to properties of `window` and `document`, see [`<svelte:window>`](svelte-window) and [`<svelte:document>`](svelte-document).
284+
257285
## Contenteditable bindings
258286

259287
Elements with the `contenteditable` attribute support the following bindings:
@@ -278,14 +306,18 @@ All visible elements have the following readonly bindings, measured with a `Resi
278306
- [`clientHeight`](https://developer.mozilla.org/en-US/docs/Web/API/Element/clientHeight)
279307
- [`offsetWidth`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetWidth)
280308
- [`offsetHeight`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetHeight)
309+
- [`contentRect`](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserverEntry/contentRect)
310+
- [`contentBoxSize`](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserverEntry/contentBoxSize)
311+
- [`borderBoxSize`](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserverEntry/borderBoxSize)
312+
- [`devicePixelContentBoxSize`](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserverEntry/devicePixelContentBoxSize)
281313

282314
```svelte
283315
<div bind:offsetWidth={width} bind:offsetHeight={height}>
284316
<Chart {width} {height} />
285317
</div>
286318
```
287319

288-
> [!NOTE] `display: inline` elements do not have a width or height (except for elements with 'intrinsic' dimensions, like `<img>` and `<canvas>`), and cannot be observed with a `ResizeObserver`. You will need to change the `display` style of these elements to something else, such as `inline-block`.
320+
> [!NOTE] `display: inline` elements do not have a width or height (except for elements with 'intrinsic' dimensions, like `<img>` and `<canvas>`), and cannot be observed with a `ResizeObserver`. You will need to change the `display` style of these elements to something else, such as `inline-block`. Note that CSS transformations do not trigger `ResizeObserver` callbacks.
289321
290322
## bind:this
291323

0 commit comments

Comments
 (0)