Skip to content

Svelte component to format numbers in an input or as a text.

Notifications You must be signed in to change notification settings

craigcosmo/svelte-number-format

 
 

Repository files navigation

svelte-number-format

Number input component with prefixes and masks for Svelte 3.

Usage

Install with npm or yarn:

npm install --save svelte-number-format

Props

  • value - the value of the input
  • placeholder - the placeholder of the input (optional)
  • displayType - can be text or input (by default: input)
  • prefix - set characters before the input (optional)
  • mask - the mask of the input, (example: "+{7}(000)000-00-00") (optional)

Example

<script lang="ts">
  import NumberFormat from 'svelte-number-format'
  let inputValue = ''

  $: console.log(inputValue)
</script>

<NumberFormat
  mask="+{7}(000)000-00-00"
  bind:value="{inputValue}"
  displayType="input"
/>

License

MIT © Pitis Radu

About

Svelte component to format numbers in an input or as a text.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 37.6%
  • Svelte 32.7%
  • TypeScript 16.7%
  • HTML 13.0%