Skip to content

Commit 4a2b683

Browse files
committed
Document display-only masks
1 parent 5c6c602 commit 4a2b683

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

  • packages/docs/src/en/plugins

packages/docs/src/en/plugins/mask.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,29 @@ You can also override the default precision of 2 digits by using any desired num
184184
<input type="text" x-mask:dynamic="$money($input, '.', ',', 4)" placeholder="0.0001">
185185
</div>
186186
<!-- END_VERBATIM -->
187+
188+
<a name="display-only-masks"></a>
189+
190+
## Display-only Masks
191+
192+
By default, any formatting applied by `x-mask` is included in the value stored by `x-model`.
193+
194+
If you only want the mask to affect what is displayed in the input, use the `.display` modifier. The input will display the masked value, while the bound property stores the unmasked value.
195+
196+
```alpine
197+
<div x-data="{ amount: '1000' }">
198+
<input x-mask:dynamic.display="$money($input)" x-model="amount">
199+
200+
<p>Model value: <span x-text="amount"></span></p>
201+
</div>
202+
```
203+
204+
<!-- START_VERBATIM -->
205+
<div class="demo" x-data="{ amount: '1000' }">
206+
<input x-mask:dynamic.display="$money($input)" x-model="amount">
207+
208+
<div class="pt-4">Model value: <span x-text="amount"></span></div>
209+
</div>
210+
<!-- END_VERBATIM -->
211+
212+
In the above example, the input displays `1,000`, while `amount` remains `1000`. If `amount` is changed programmatically, the input will display the newly formatted value.

0 commit comments

Comments
 (0)