2
0
mirror of https://github.com/tenrok/maska.git synced 2026-05-15 11:59:38 +03:00
Files
maska/docs/v3/svelte.md
T
Alexander Shabunevich c659a3d585 docs: updated docs for v3
2024-05-29 22:36:46 +03:00

1.1 KiB

Usage with Svelte

Installation

You can install Maska with following command:

npm install @maskajs/svelte@3

And then use it in your .svelte component:

import { maska } from '@maskajs/svelte'

<input use:maska data-maska="#-#" />

Action signature

Maska provides simple Svelte action for use with input:

<input use:maska={options}>
  • options is object with default options

Minimal example

Apply maska action to the input along with data-maska attribite:

<script>
import { maska } from '@maskajs/svelte'
</script>

<input use:maska data-maska="#-#">

Set mask options

To set default options for the mask, pass options via directive value:

<script>
import { maska } from '@maskajs/svelte'

const options = {
  mask: "#-#",
  eager: true
}
</script>

<input use:maska={options} data-maska-reversed>

You can override default options with data-maska- attributes on the input. In the example above we set eager mode using options and reversed mode using data-maska-reversed attribute.