Svelte numeric input
Numora is a Svelte numeric input library. It handles thousand separators, decimal limits, paste sanitization, scientific-notation expansion and cursor preservation through a use:numora action. Svelte's use: actions suit libraries that own a DOM node, as NumoraInput does. You need no numora-svelte wrapper, no peer dependencies and no SSR special-casing. The vanilla package is framework-agnostic TypeScript, 8.3 kB gzipped, with zero runtime dependencies.
Installation
Svelte action
NumoraInput attaches directly to an existing <input> element. A Svelte action binds that lifecycle to a DOM node. Add this helper to your project once and reuse it everywhere.
src/lib/numora.ts:
Component <script lang="ts">:
Component markup:
Numora adopts the <input> and sets the attributes it needs. onValueChange receives { value, formattedValue }, where value is the raw string (see value types). By default, Numora formats on every keystroke (see formatting).
Read the value from onValueChange, not from bind:value. The element's own value is the display string ("1,234.56"). onValueChange gives you the raw value ("1234.56").
Animated example: Numora + Torph in Svelte
Stack a Torph TextMorph over a transparent-text NumoraInput. The Torph integration explains the overlay and has the shared CSS and install steps. Below is the Svelte 5 action.
src/lib/numora-torph.ts is an action that mounts NumoraInput and TextMorph in the same wrapper. Its destroy hook tears down both:
Component <script lang="ts">:
Markup:
Use the overlay CSS from the Torph page in the component's <style> block. Wrap selectors that target the runtime-created <input> in :global(), because Svelte's scoped styles cannot reach it otherwise:
FAQ
What is the best Svelte numeric input library?
Numora is framework-agnostic TypeScript, 8.3 kB gzipped, with no runtime dependencies. In Svelte you wrap NumoraInput in a small use:numora action and mount it directly on an <input>.
Is there a numora-svelte package?
No, and you do not need one. The Svelte action is the entire adapter.
Does Numora work with SvelteKit and SSR?
Yes. NumoraInput touches the DOM, so initialize it inside an action or onMount. Both only run in the browser. SvelteKit renders the empty <input> on the server and the action adopts it in the browser. You need no SSR-specific configuration.
How do I add thousand separators to a Svelte number input?
Nothing to configure. Grouping on every keystroke is the default. Numora formats as the user types and keeps the cursor between the same two digits when it inserts a comma. onValueChange receives { value, formattedValue }, where value is the raw value without separators, which you can store in a Svelte store or pass to a form library.
Does it support i18n (decimal commas, locale grouping) in Svelte?
Yes. Set decimalSeparator: ',' and thousandSeparator: '.' (or use the locale option) for European locales. The raw value is a plain dot-decimal string in every locale.
Why not use a normal <input> with bind:value?
A plain bind:value has no thousand separators, decimal limits or paste sanitization, and you would have to write the cursor-positioning logic yourself. Numora handles all of it.
Can I animate digits in Svelte?
Yes. The Torph integration is also framework-agnostic. The same vanilla TextMorph overlay pattern works inside a Svelte component, and Torph respects prefers-reduced-motion by default.