Skip to main content
Create new
Introduction
Reactivity
Props
Logic
Events
Bindings
Lifecycle
Stores
Motion
Transitions
Animations
Easing
SVG
Actions
Classes
Component composition
Context API
Special elements
Module context
Debugging
7GUIs
Miscellaneous
App.svelte
NavLink.svelte
NavLink2.svelte
hash.js
<script>
import NavLink from './NavLink.svelte'
import NavLink2 from './NavLink2.svelte'
import hash from './hash'

window.location.hash = '#/'
</script>

<nav>
<div>
<NavLink href="#/">Home</NavLink>
<NavLink href="#/long">A Very Long Name</NavLink>
<NavLink href="#/articles">Articles</NavLink>
</div>
<div>
<NavLink2 href="#/">Home</NavLink2>
<NavLink2 href="#/long">A Very Long Name</NavLink2>
<NavLink2 href="#/articles">Articles</NavLink2>
</div>
</nav>

{#if $hash === '#/articles'}
<p>Articles</p>
{:else if $hash === '#/long'}
<p>Long Indeed</p>
{:else}
<p>Home</p>
{/if}

<style>
nav {
text-align: center;
}
</style>
loading Svelte compiler...
/* Select a component to see its compiled code */
result = svelte.compile(source, {
generate: ,
});
/* Select a component to see its compiled code */