Display HTML in Svelte

If you want to display HTML, you can use the @html keyword and place it in front of your value.

<script>
    let input = "<h1>This is html</h1>";
</script>
<main>
    {@html input}
</main>

You can display Tailwind Classes this way

let input = "<h1 class='text-4xl text-red-500'>hello</h1>";

Last updated