Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR HTML

svelte if block

<script>
	let user = { loggedIn: false };
	let toggle = () => user.loggedIn = !user.loggedIn;
</script>

{#if user.loggedIn}
	<button on:click={toggle}>Log out</button>
{/if}

{#if !user.loggedIn}
	<button on:click={toggle}>Log in</button>
{/if}
Source by svelte.dev #
 
PREVIOUS NEXT
Tagged: #svelte #block
ADD COMMENT
Topic
Name
9+4 =