mirror of
https://github.com/tenrok/maska.git
synced 2026-05-30 15:24:06 +03:00
43 lines
854 B
Markdown
43 lines
854 B
Markdown
# Usage with Svelte
|
|
|
|
Maska provides simple Svelte action for use with input:
|
|
|
|
```html
|
|
<input use:maska={options}>
|
|
```
|
|
|
|
- `options` is object with default options
|
|
|
|
|
|
## Minimal example
|
|
|
|
Apply `maska` action to the input along with `data-maska` attribite:
|
|
|
|
```svelte
|
|
<script>
|
|
import { maska } from '@maskajs/svelte'
|
|
</script>
|
|
|
|
<input use:maska data-maska="#-#">
|
|
```
|
|
|
|
|
|
## Set mask options
|
|
|
|
To set default [options](/options) for the mask, pass options via **directive value**:
|
|
|
|
```svelte
|
|
<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.
|