Svelte allows us to explicitly show an element if the array to be looped is found empty. It's a feature that's exclusively available to Svelte among other SPA frameworks. Let's…
How to loop through a list of data and render it in Svelte | Example
Svelte allows us to loop through a list of data using the #each block. Let's have a look at this example to understand how it works. We're going to add…
How to show HTML conditionally using if-else statements in Svelte | Example
Like any other SPA framework, Svelte allows us to show parts of HTML or components conditionally. If we compare it with React, in React we return a fragment/component for each…
How to bind CSS classes conditionally in Svelte | Example
More often than not, we'd need to bind CSS class names conditionally. One of the prime examples is form validation. We often like to highlight to show erroneous messages in…
How to parse and output HTML in Svelte | Example
By default, if we try to input some HTML value in a text input or a textarea input and display it directly, it won't parse it as HTML. That is,…
How to pass props to components in Svelte | Example
Earlier we saw how we can import one component into another in Svelte. But this is not of much use if we cannot pass some values to the components we…
How to import one component inside another in Svelte | Example
Svelte has probably one of the most compact syntaxes to import components. All other SPA frameworks seem to demand more code lines. Let's have a look at an example. In…
How to do two-way data binding in Svelte | Example
In the previous example, we learned how we can do two-way data binding in Svelte by using the :on event listener. However, it required us two steps to bind a…
How to auto-lowercase user input in Svelte | Example
In the previous article, we saw how we can use reactive declaration $ in Svelte. In this article, we'll have a look at how we can automatically lowercase the user…
- 1
- 2