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
<script lang="ts">
import CurrencyInput from '@canutin/svelte-currency-input';

let output;
const handleSubmit = (event) => {
event.preventDefault();
// Get the form data
const data = new FormData(event.target);
// Pretty-print the data as JSON
output = JSON.stringify(Object.fromEntries(data.entries()), null, 2);
};
let formState = {
AskPrice: -42069.33
}
</script>

<form class="demoForm" on:submit={handleSubmit}>
<div class="demoForm__container">
<CurrencyInput name="default" bind:value={formState.AskPrice} />
</div>

<nav class="demoForm__output">
<button type="submit" class="demoForm__submit">Submit form</button>

<pre class="demoForm__pre {!output && 'demoForm__pre--placeholder'}">{output
? output
: 'Submit form to see a JSON output of the values'}</pre>
</nav>

<nav class="demoForm__nav">
<a class="demoForm__a" href="https://github.com/canutin/svelte-currency-input" target="_blank"
>GitHub repository</a
>
<a
class="demoForm__a"
loading Svelte compiler...
/* Select a component to see its compiled code */
result = svelte.compile(source, {
generate: ,
});
/* Select a component to see its compiled code */