Advanced Svelte
Advanced Svelte
Advanced Reactivity
- Raw State
Characteristics: Changes to properties and content will not trigger updates
| |
- Reactive Classes
| |
- Built-in Reactive Classes
Supports Map, Set, Date, URL, URLSearchParams
| |
store
Content Reuse
#snippet
snippets can also be passed to child components as props
| |
- Passing snippets as component props
| |
Motion
- Tween
| |
- Spring
| |
Advanced (Two-way) Binding
- contenteditable
Supports binding textContent and innerHTML
| |
- each blocks
| |
- Media elements
| |
- Dimensions
Supports clientWidth, clientHeight, offsetWidth, offsetHeight
Read-only bindings
| |
- DOM Elements
Read-only bindings
| |
- Making component props bindable
| |
- Component Instances
| |
Advanced Transitions
- Deferred Transitions
| |
| |
- Animations (
animate:)
Provides animation effects for elements that are not transitioning
| |
Context
| |
Special Elements
<svelte:window>- Can add event listeners
- Can bind innerWidth, innerHeight, outerWidth, outerHeight, scrollX, scrollY, online (window.navigator.onLine). All are read-only except scrollX and scrollY.
<svelte:document>- Can add event listeners
<svelte:body>- Can add event listeners
<svelte:head>- Allows adding content to the HTML
<head> - In SSR mode, it will be returned separately from other HTML content
- Allows adding content to the HTML
<svelte:element>- Can specify the type of the element via the
thisproperty
- Can specify the type of the element via the
| |
<svelte:boundary>- Used to handle component loading errors
| |
<script module>
Decouples code from component instances
- Code will only run when the module is first evaluated
- Can use
exportto export (but cannot use default export, as the default export is the component itself)
Last updated on