Author: Awais Farooq
-
Transitions
Animations in Svelte are first-class so you don’t have to reach for an animation library unless you want to. To use transitions you can import blur, fly, slide, scale, draw and crossfade from svelte/transition. To use a transition use transition:fade. You can specify parameters such as delay, duration, easing for fade. To learn what they are for each transition consult the documentation. App.svelteCopy You can specify a enter animation with in:fade and exit animation…
-
Slots
In Svelte we can use slots to compose components meaning our components can contain other components and elements to be more reusable like regular HTML. Example.htmlCopy The <slot> element lets us do that with components. If you’re familiar with React this is similar to the children prop and Vue also has slots. We can provide a fallback if no content is provided.…
-
Components
Components are the primary reason of using any modern JavaScript framework because it lets you organize code and have your concerns in one place. If you ever used classes you can think of components as new instances of a class that can be used as a blueprint to have its own independent state. It’s easy to get carried away…
-
Bindings
Data binding is keeping your application state and user interface synchronized. Svelte supports data binding using the bind: directive. Often you have a value that other parts depend on for example if you had a text search input and want to filter a list of items whenever the user types a search query. You can implement data binding in…