@ui-sdk/vue 0.0.0-stage → 0.1.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (262) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +10 -2
  3. package/dist/accordion.d.ts +561 -0
  4. package/dist/accordion.js +24 -0
  5. package/dist/agent.d.ts +2 -0
  6. package/dist/agent.js +7 -0
  7. package/dist/alert-dialog.d.ts +231 -0
  8. package/dist/alert-dialog.js +33 -0
  9. package/dist/async-options.d.ts +18 -0
  10. package/dist/async-options.js +40 -0
  11. package/dist/autocomplete.d.ts +384 -0
  12. package/dist/autocomplete.js +344 -0
  13. package/dist/avatar.d.ts +40 -0
  14. package/dist/avatar.js +28 -0
  15. package/dist/button.d.ts +52 -0
  16. package/dist/button.js +43 -0
  17. package/dist/calendar-context.d.ts +10 -0
  18. package/dist/calendar-context.js +7 -0
  19. package/dist/calendar.d.ts +311 -0
  20. package/dist/calendar.js +349 -0
  21. package/dist/carousel.d.ts +236 -0
  22. package/dist/carousel.js +204 -0
  23. package/dist/checkbox.d.ts +211 -0
  24. package/dist/checkbox.js +151 -0
  25. package/dist/children.d.ts +41 -0
  26. package/dist/children.js +135 -0
  27. package/dist/collapsible.d.ts +54 -0
  28. package/dist/collapsible.js +18 -0
  29. package/dist/color-picker.d.ts +187 -0
  30. package/dist/color-picker.js +158 -0
  31. package/dist/color.d.ts +2 -0
  32. package/dist/color.js +21 -0
  33. package/dist/combobox.d.ts +517 -0
  34. package/dist/combobox.js +531 -0
  35. package/dist/command.d.ts +322 -0
  36. package/dist/command.js +345 -0
  37. package/dist/controller-target.d.ts +49 -0
  38. package/dist/controller-target.js +112 -0
  39. package/dist/create-parts.d.ts +126 -0
  40. package/dist/create-parts.js +206 -0
  41. package/dist/date-input.d.ts +133 -0
  42. package/dist/date-input.js +31 -0
  43. package/dist/date-picker.d.ts +328 -0
  44. package/dist/date-picker.js +354 -0
  45. package/dist/date.d.ts +2 -0
  46. package/dist/date.js +59 -0
  47. package/dist/dialog-parts.d.ts +259 -0
  48. package/dist/dialog-parts.js +300 -0
  49. package/dist/dialog.d.ts +251 -0
  50. package/dist/dialog.js +25 -0
  51. package/dist/drawer.d.ts +304 -0
  52. package/dist/drawer.js +373 -0
  53. package/dist/editor-context.d.ts +4 -0
  54. package/dist/editor-context.js +5 -0
  55. package/dist/field-context.d.ts +26 -0
  56. package/dist/field-context.js +44 -0
  57. package/dist/field.d.ts +154 -0
  58. package/dist/field.js +240 -0
  59. package/dist/file-input.d.ts +212 -0
  60. package/dist/file-input.js +255 -0
  61. package/dist/form-inputs.d.ts +16 -0
  62. package/dist/form-inputs.js +25 -0
  63. package/dist/gesture.d.ts +1 -0
  64. package/dist/gesture.js +15 -0
  65. package/dist/history.d.ts +2 -0
  66. package/dist/history.js +11 -0
  67. package/dist/hover-card.d.ts +137 -0
  68. package/dist/hover-card.js +153 -0
  69. package/dist/image-cropper.d.ts +74 -0
  70. package/dist/image-cropper.js +36 -0
  71. package/dist/image.d.ts +2 -0
  72. package/dist/image.js +5 -0
  73. package/dist/index.d.ts +59 -0
  74. package/dist/index.js +60 -0
  75. package/dist/input.d.ts +120 -0
  76. package/dist/input.js +73 -0
  77. package/dist/item-icon.d.ts +34 -0
  78. package/dist/item-icon.js +63 -0
  79. package/dist/label.d.ts +16 -0
  80. package/dist/label.js +8 -0
  81. package/dist/lifecycle.d.ts +11 -0
  82. package/dist/lifecycle.js +91 -0
  83. package/dist/list-items.d.ts +38 -0
  84. package/dist/list-items.js +59 -0
  85. package/dist/list-text.d.ts +7 -0
  86. package/dist/list-text.js +15 -0
  87. package/dist/listbox.d.ts +273 -0
  88. package/dist/listbox.js +126 -0
  89. package/dist/menu.d.ts +678 -0
  90. package/dist/menu.js +607 -0
  91. package/dist/menubar-context.d.ts +5 -0
  92. package/dist/menubar-context.js +5 -0
  93. package/dist/menubar.d.ts +61 -0
  94. package/dist/menubar.js +48 -0
  95. package/dist/meter.d.ts +41 -0
  96. package/dist/meter.js +37 -0
  97. package/dist/navigation-menu.d.ts +228 -0
  98. package/dist/navigation-menu.js +195 -0
  99. package/dist/number-input.d.ts +176 -0
  100. package/dist/number-input.js +231 -0
  101. package/dist/number.d.ts +2 -0
  102. package/dist/number.js +39 -0
  103. package/dist/nuxt/entries.json +977 -0
  104. package/dist/nuxt/module.d.ts +18 -0
  105. package/dist/nuxt/module.js +31 -0
  106. package/dist/nuxt/registrations.d.ts +22 -0
  107. package/dist/nuxt/registrations.js +22 -0
  108. package/dist/observe.d.ts +2 -0
  109. package/dist/observe.js +7 -0
  110. package/dist/otp-input.d.ts +142 -0
  111. package/dist/otp-input.js +130 -0
  112. package/dist/overlays.d.ts +40 -0
  113. package/dist/overlays.js +118 -0
  114. package/dist/pagination.d.ts +201 -0
  115. package/dist/pagination.js +146 -0
  116. package/dist/password-input.d.ts +144 -0
  117. package/dist/password-input.js +134 -0
  118. package/dist/popover.d.ts +211 -0
  119. package/dist/popover.js +258 -0
  120. package/dist/popup.d.ts +60 -0
  121. package/dist/popup.js +89 -0
  122. package/dist/preferences.d.ts +44 -0
  123. package/dist/preferences.js +102 -0
  124. package/dist/primitive.d.ts +2 -0
  125. package/dist/primitive.js +11 -0
  126. package/dist/progress.d.ts +41 -0
  127. package/dist/progress.js +37 -0
  128. package/dist/radio.d.ts +164 -0
  129. package/dist/radio.js +145 -0
  130. package/dist/rating.d.ts +149 -0
  131. package/dist/rating.js +146 -0
  132. package/dist/renderless.d.ts +4 -0
  133. package/dist/renderless.js +28 -0
  134. package/dist/resizable.d.ts +54 -0
  135. package/dist/resizable.js +22 -0
  136. package/dist/scroll-area.d.ts +72 -0
  137. package/dist/scroll-area.js +77 -0
  138. package/dist/segmented-control.d.ts +151 -0
  139. package/dist/segmented-control.js +110 -0
  140. package/dist/segmented-input.d.ts +76 -0
  141. package/dist/segmented-input.js +115 -0
  142. package/dist/select.d.ts +458 -0
  143. package/dist/select.js +468 -0
  144. package/dist/separator.d.ts +14 -0
  145. package/dist/separator.js +8 -0
  146. package/dist/shortcuts.d.ts +32 -0
  147. package/dist/shortcuts.js +56 -0
  148. package/dist/slider.d.ts +65 -0
  149. package/dist/slider.js +194 -0
  150. package/dist/switch.d.ts +103 -0
  151. package/dist/switch.js +71 -0
  152. package/dist/tabs.d.ts +338 -0
  153. package/dist/tabs.js +27 -0
  154. package/dist/text-control.d.ts +89 -0
  155. package/dist/text-control.js +51 -0
  156. package/dist/text-match.d.ts +2 -0
  157. package/dist/text-match.js +7 -0
  158. package/dist/textarea.d.ts +106 -0
  159. package/dist/textarea.js +68 -0
  160. package/dist/time-input.d.ts +131 -0
  161. package/dist/time-input.js +32 -0
  162. package/dist/timeline.d.ts +81 -0
  163. package/dist/timeline.js +30 -0
  164. package/dist/toast-parts.d.ts +203 -0
  165. package/dist/toast-parts.js +270 -0
  166. package/dist/toast.d.ts +2 -0
  167. package/dist/toast.js +21 -0
  168. package/dist/toggle-props.d.ts +22 -0
  169. package/dist/toggle-props.js +14 -0
  170. package/dist/toggle.d.ts +199 -0
  171. package/dist/toggle.js +129 -0
  172. package/dist/token-input.d.ts +136 -0
  173. package/dist/token-input.js +214 -0
  174. package/dist/toolbar-context.d.ts +7 -0
  175. package/dist/toolbar-context.js +20 -0
  176. package/dist/toolbar.d.ts +120 -0
  177. package/dist/toolbar.js +77 -0
  178. package/dist/tooltip.d.ts +160 -0
  179. package/dist/tooltip.js +224 -0
  180. package/dist/tree.d.ts +300 -0
  181. package/dist/tree.js +209 -0
  182. package/dist/trigger-menu.d.ts +452 -0
  183. package/dist/trigger-menu.js +254 -0
  184. package/dist/use-primitive.d.ts +132 -0
  185. package/dist/use-primitive.js +462 -0
  186. package/dist/waterfall.d.ts +201 -0
  187. package/dist/waterfall.js +171 -0
  188. package/docs/README.md +89 -0
  189. package/docs/agents.md +1523 -0
  190. package/docs/components/accordion.md +1369 -0
  191. package/docs/components/alert-dialog.md +799 -0
  192. package/docs/components/autocomplete.md +1857 -0
  193. package/docs/components/avatar.md +272 -0
  194. package/docs/components/button.md +435 -0
  195. package/docs/components/calendar.md +1589 -0
  196. package/docs/components/carousel.md +1171 -0
  197. package/docs/components/checkbox.md +1008 -0
  198. package/docs/components/collapsible.md +536 -0
  199. package/docs/components/color-picker.md +706 -0
  200. package/docs/components/combobox.md +3504 -0
  201. package/docs/components/command.md +1481 -0
  202. package/docs/components/date-input.md +536 -0
  203. package/docs/components/date-picker.md +1244 -0
  204. package/docs/components/dialog.md +1397 -0
  205. package/docs/components/drawer.md +1166 -0
  206. package/docs/components/field.md +538 -0
  207. package/docs/components/file-input.md +611 -0
  208. package/docs/components/hover-card.md +505 -0
  209. package/docs/components/image-cropper.md +556 -0
  210. package/docs/components/input.md +306 -0
  211. package/docs/components/label.md +203 -0
  212. package/docs/components/listbox.md +1004 -0
  213. package/docs/components/menu.md +1229 -0
  214. package/docs/components/menubar.md +443 -0
  215. package/docs/components/meter.md +315 -0
  216. package/docs/components/navigation-menu.md +1523 -0
  217. package/docs/components/number-input.md +1029 -0
  218. package/docs/components/otp-input.md +512 -0
  219. package/docs/components/pagination.md +613 -0
  220. package/docs/components/password-input.md +649 -0
  221. package/docs/components/popover.md +1448 -0
  222. package/docs/components/preferences.md +208 -0
  223. package/docs/components/progress.md +423 -0
  224. package/docs/components/radio.md +785 -0
  225. package/docs/components/rating.md +416 -0
  226. package/docs/components/resizable.md +910 -0
  227. package/docs/components/scroll-area.md +915 -0
  228. package/docs/components/segmented-control.md +435 -0
  229. package/docs/components/select.md +2015 -0
  230. package/docs/components/separator.md +229 -0
  231. package/docs/components/slider.md +1084 -0
  232. package/docs/components/switch.md +565 -0
  233. package/docs/components/tabs.md +944 -0
  234. package/docs/components/textarea.md +299 -0
  235. package/docs/components/time-input.md +224 -0
  236. package/docs/components/timeline.md +654 -0
  237. package/docs/components/toast.md +1224 -0
  238. package/docs/components/toggle.md +500 -0
  239. package/docs/components/token-input.md +953 -0
  240. package/docs/components/toolbar.md +739 -0
  241. package/docs/components/tooltip.md +818 -0
  242. package/docs/components/tree.md +1306 -0
  243. package/docs/components/trigger-menu.md +1223 -0
  244. package/docs/components/waterfall.md +717 -0
  245. package/docs/controllers.md +71 -0
  246. package/docs/core.md +8027 -0
  247. package/docs/custom-parts.md +89 -0
  248. package/docs/first-component.md +83 -0
  249. package/docs/forms.md +122 -0
  250. package/docs/installation.md +72 -0
  251. package/docs/introduction.md +32 -0
  252. package/docs/lists-and-menus.md +122 -0
  253. package/docs/llms.txt +1502 -0
  254. package/docs/parts-and-composition.md +85 -0
  255. package/docs/popups.md +108 -0
  256. package/docs/rendering.md +56 -0
  257. package/docs/server-rendering.md +180 -0
  258. package/docs/state-and-events.md +100 -0
  259. package/docs/styling-and-animation.md +148 -0
  260. package/docs/utilities/async-options.md +348 -0
  261. package/docs/utilities/shortcuts.md +159 -0
  262. package/package.json +352 -3
@@ -0,0 +1,1029 @@
1
+ # Number Input
2
+
3
+ Enter numbers, step through values, and format them for a locale.
4
+
5
+ Use a Number Input for quantities, prices and measurements. It keeps a numeric value while showing formatted text, and steps it with the keyboard, the step buttons, or a drag on its label.
6
+
7
+ ```vue title="basic.vue"
8
+ <script setup lang="ts">
9
+ import { MinusIcon, MoveHorizontalIcon, PlusIcon } from "@lucide/vue"
10
+ import { Field, FieldLabel } from "@ui-sdk/vue/field"
11
+ import {
12
+ NumberInput,
13
+ NumberInputControl,
14
+ NumberInputDecrement,
15
+ NumberInputGroup,
16
+ NumberInputIncrement,
17
+ NumberInputScrubArea,
18
+ NumberInputScrubAreaCursor,
19
+ } from "@ui-sdk/vue/number-input"
20
+ import { useLog } from "./log"
21
+
22
+ const log = useLog()
23
+ </script>
24
+
25
+ <template>
26
+ <Field>
27
+ <NumberInput
28
+ :default-value="1"
29
+ :min="1"
30
+ @value-commit="(value) => log(`Quantity ${value ?? 'empty'}`)"
31
+ >
32
+ <NumberInputScrubArea :pixels-per-step="4">
33
+ <FieldLabel>Quantity</FieldLabel>
34
+ <NumberInputScrubAreaCursor>
35
+ <MoveHorizontalIcon aria-hidden="true" />
36
+ </NumberInputScrubAreaCursor>
37
+ </NumberInputScrubArea>
38
+ <NumberInputGroup>
39
+ <NumberInputDecrement aria-label="Decrease">
40
+ <MinusIcon aria-hidden="true" />
41
+ </NumberInputDecrement>
42
+ <NumberInputControl />
43
+ <NumberInputIncrement aria-label="Increase">
44
+ <PlusIcon aria-hidden="true" />
45
+ </NumberInputIncrement>
46
+ </NumberInputGroup>
47
+ </NumberInput>
48
+ </Field>
49
+ </template>
50
+ ```
51
+
52
+ Drag the Quantity label sideways to scrub the value, or click it to focus the input. Type a number, press ArrowUp or ArrowDown, or hold a step button. The console logs the value once each change is committed.
53
+
54
+ ## Installation
55
+
56
+ ```bash
57
+ npm install @ui-sdk/vue @ui-sdk/core
58
+ ```
59
+
60
+ ## Composition
61
+
62
+ Use the following composition to build a `NumberInput`:
63
+
64
+ ```text
65
+ NumberInput
66
+ ├── NumberInputScrubArea
67
+ │ └── NumberInputScrubAreaCursor
68
+ └── NumberInputGroup
69
+ ├── NumberInputDecrement
70
+ ├── NumberInputControl
71
+ └── NumberInputIncrement
72
+ ```
73
+
74
+ `NumberInput` holds the numeric value. `NumberInputGroup` wraps the text input and the optional step buttons. `NumberInputControl` renders the input; `NumberInputDecrement` and `NumberInputIncrement` change its value and repeat while held. `NumberInputScrubArea` is optional and changes the value as you drag it.
75
+
76
+ Typing updates the value when the text is valid and within bounds. Enter or blur commits it: the text is parsed, clamped, snapped to the step, and formatted. An empty input has the value `null`.
77
+
78
+ ## Usage
79
+
80
+ Import the parts and put them together:
81
+
82
+ ```vue
83
+ <script setup lang="ts">
84
+ import {
85
+ NumberInput,
86
+ NumberInputGroup,
87
+ NumberInputControl,
88
+ NumberInputDecrement,
89
+ NumberInputIncrement,
90
+ } from "@ui-sdk/vue/number-input"
91
+ </script>
92
+
93
+ <template>
94
+ <NumberInput :default-value="1" :min="0">
95
+ <NumberInputGroup>
96
+ <NumberInputDecrement aria-label="Decrease">−</NumberInputDecrement>
97
+ <NumberInputControl aria-label="Quantity" />
98
+ <NumberInputIncrement aria-label="Increase">+</NumberInputIncrement>
99
+ </NumberInputGroup>
100
+ </NumberInput>
101
+ </template>
102
+ ```
103
+
104
+ ## Field
105
+
106
+ Wrap the number input in [Field](./field.md) to give it a visible label and a description.
107
+
108
+ ```vue title="field.vue"
109
+ <script setup lang="ts">
110
+ import { MinusIcon, PlusIcon } from "@lucide/vue"
111
+ import { Field, FieldDescription, FieldLabel } from "@ui-sdk/vue/field"
112
+ import {
113
+ NumberInput,
114
+ NumberInputControl,
115
+ NumberInputDecrement,
116
+ NumberInputGroup,
117
+ NumberInputIncrement,
118
+ } from "@ui-sdk/vue/number-input"
119
+ </script>
120
+
121
+ <template>
122
+ <Field>
123
+ <FieldLabel>Tickets</FieldLabel>
124
+ <NumberInput :default-value="2" :min="1">
125
+ <NumberInputGroup>
126
+ <NumberInputDecrement aria-label="Decrease">
127
+ <MinusIcon aria-hidden="true" />
128
+ </NumberInputDecrement>
129
+ <NumberInputControl />
130
+ <NumberInputIncrement aria-label="Increase">
131
+ <PlusIcon aria-hidden="true" />
132
+ </NumberInputIncrement>
133
+ </NumberInputGroup>
134
+ </NumberInput>
135
+ <FieldDescription
136
+ >Each ticket admits one person to the workshop.</FieldDescription
137
+ >
138
+ </Field>
139
+ </template>
140
+ ```
141
+
142
+ Click Tickets to focus the input, then type or step its value. Screen readers read the description with the field.
143
+
144
+ ## Min and Max
145
+
146
+ Use `min` and `max` to set bounds. A step button disables at its bound. Typed values outside the bounds are clamped when committed.
147
+
148
+ ```vue title="min-max.vue"
149
+ <script setup lang="ts">
150
+ import { MinusIcon, PlusIcon } from "@lucide/vue"
151
+ import { Field, FieldDescription, FieldLabel } from "@ui-sdk/vue/field"
152
+ import {
153
+ NumberInput,
154
+ NumberInputControl,
155
+ NumberInputDecrement,
156
+ NumberInputGroup,
157
+ NumberInputIncrement,
158
+ } from "@ui-sdk/vue/number-input"
159
+ </script>
160
+
161
+ <template>
162
+ <Field>
163
+ <FieldLabel>Guests</FieldLabel>
164
+ <NumberInput :default-value="2" :min="1" :max="8">
165
+ <NumberInputGroup>
166
+ <NumberInputDecrement aria-label="Decrease">
167
+ <MinusIcon aria-hidden="true" />
168
+ </NumberInputDecrement>
169
+ <NumberInputControl />
170
+ <NumberInputIncrement aria-label="Increase">
171
+ <PlusIcon aria-hidden="true" />
172
+ </NumberInputIncrement>
173
+ </NumberInputGroup>
174
+ </NumberInput>
175
+ <FieldDescription>Tables seat between 1 and 8 guests.</FieldDescription>
176
+ </Field>
177
+ </template>
178
+ ```
179
+
180
+ Change Guests between 1 and 8. Type 20 and press Enter to clamp it to 8. At either bound, that direction's step button is disabled.
181
+
182
+ ## Step and Large Step
183
+
184
+ `step` sets the usual increment, and defaults to 1. Steps are measured from `min`, or from zero when no minimum is set. When they don't land on `max`, End and the increment button stop at the highest step below it, so stepping keeps the value on the step grid, as [Slider](./slider.md#step-and-bounds) does. Shift, Page Up and Page Down use `large-step`, ten steps by default, and Alt (Option) with an arrow key uses `small-step`, a tenth of a step. [Keyboard](#keyboard) lists every key.
185
+
186
+ ```vue title="step.vue"
187
+ <script setup lang="ts">
188
+ import { MinusIcon, PlusIcon } from "@lucide/vue"
189
+ import { Field, FieldDescription, FieldLabel } from "@ui-sdk/vue/field"
190
+ import {
191
+ NumberInput,
192
+ NumberInputControl,
193
+ NumberInputDecrement,
194
+ NumberInputGroup,
195
+ NumberInputIncrement,
196
+ } from "@ui-sdk/vue/number-input"
197
+ </script>
198
+
199
+ <template>
200
+ <Field>
201
+ <FieldLabel>Hours</FieldLabel>
202
+ <NumberInput :default-value="1.5" :min="0" :max="24" :step="0.25" :large-step="1" :small-step="0.05">
203
+ <NumberInputGroup>
204
+ <NumberInputDecrement aria-label="Decrease">
205
+ <MinusIcon aria-hidden="true" />
206
+ </NumberInputDecrement>
207
+ <NumberInputControl />
208
+ <NumberInputIncrement aria-label="Increase">
209
+ <PlusIcon aria-hidden="true" />
210
+ </NumberInputIncrement>
211
+ </NumberInputGroup>
212
+ </NumberInput>
213
+ <FieldDescription>Logged in quarter hours.</FieldDescription>
214
+ </Field>
215
+ </template>
216
+ ```
217
+
218
+ Step Hours by 0.25. Hold Shift to move by 1, or hold Alt (Option) with an arrow key to move by 0.05. Home and End go to 0 and 24.
219
+
220
+ ## Format
221
+
222
+ Pass `Intl.NumberFormat` options through `format`. The input displays and parses that format while keeping a numeric value. For percentages, `0.15` is displayed as `15%`, and `step` defaults to the smallest percent the format shows: `0.01` for whole percents, `0.0001` with two fraction digits.
223
+
224
+ ```vue title="format.vue"
225
+ <script setup lang="ts">
226
+ import { MinusIcon, PlusIcon } from "@lucide/vue"
227
+ import { Field, FieldLabel } from "@ui-sdk/vue/field"
228
+ import {
229
+ NumberInput,
230
+ NumberInputControl,
231
+ NumberInputDecrement,
232
+ NumberInputGroup,
233
+ NumberInputIncrement,
234
+ } from "@ui-sdk/vue/number-input"
235
+
236
+ const fields = [
237
+ {
238
+ label: "Price",
239
+ defaultValue: 19.99,
240
+ step: 0.01,
241
+ format: { style: "currency", currency: "USD" },
242
+ },
243
+ {
244
+ label: "Discount",
245
+ defaultValue: 0.15,
246
+ step: 0.01,
247
+ format: { style: "percent" },
248
+ },
249
+ {
250
+ label: "Weight",
251
+ defaultValue: 2.5,
252
+ step: 0.1,
253
+ format: { style: "unit", unit: "kilogram" },
254
+ },
255
+ ] satisfies {
256
+ label: string
257
+ defaultValue: number
258
+ step: number
259
+ format: Intl.NumberFormatOptions
260
+ }[]
261
+ </script>
262
+
263
+ <template>
264
+ <div data-slot="stack">
265
+ <Field v-for="field in fields" :key="field.label">
266
+ <FieldLabel>{{ field.label }}</FieldLabel>
267
+ <NumberInput :default-value="field.defaultValue" :step="field.step" :format="field.format" :min="0">
268
+ <NumberInputGroup>
269
+ <NumberInputDecrement aria-label="Decrease">
270
+ <MinusIcon aria-hidden="true" />
271
+ </NumberInputDecrement>
272
+ <NumberInputControl />
273
+ <NumberInputIncrement aria-label="Increase">
274
+ <PlusIcon aria-hidden="true" />
275
+ </NumberInputIncrement>
276
+ </NumberInputGroup>
277
+ </NumberInput>
278
+ </Field>
279
+ </div>
280
+ </template>
281
+ ```
282
+
283
+ Edit Price, Discount, or Weight and leave the field to format it. Try entering 5 in Price or 25% in Discount, then use the step buttons.
284
+
285
+ ## Locale
286
+
287
+ Set `locale` to choose separators, currency symbols, and grouping. Without it, the input follows the page's language or the browser's language after mounting. Server markup uses English when no locale is provided; set a locale explicitly when that first render matters.
288
+
289
+ ```vue title="locale.vue"
290
+ <script setup lang="ts">
291
+ import { MinusIcon, PlusIcon } from "@lucide/vue"
292
+ import { Field, FieldDescription, FieldLabel } from "@ui-sdk/vue/field"
293
+ import {
294
+ NumberInput,
295
+ NumberInputControl,
296
+ NumberInputDecrement,
297
+ NumberInputGroup,
298
+ NumberInputIncrement,
299
+ } from "@ui-sdk/vue/number-input"
300
+
301
+ const fields = [
302
+ {
303
+ label: "Preis",
304
+ locale: "de-DE",
305
+ defaultValue: 1234.5,
306
+ step: 0.01,
307
+ format: { style: "currency", currency: "EUR" },
308
+ },
309
+ {
310
+ label: "Budget",
311
+ locale: "en-IN",
312
+ defaultValue: 1234567,
313
+ step: 1000,
314
+ format: { style: "currency", currency: "INR", maximumFractionDigits: 0 },
315
+ },
316
+ ] satisfies {
317
+ label: string
318
+ locale: string
319
+ defaultValue: number
320
+ step: number
321
+ format: Intl.NumberFormatOptions
322
+ }[]
323
+ </script>
324
+
325
+ <template>
326
+ <div data-slot="stack">
327
+ <Field v-for="field in fields" :key="field.label">
328
+ <FieldLabel>{{ field.label }}</FieldLabel>
329
+ <NumberInput
330
+ :default-value="field.defaultValue"
331
+ :step="field.step"
332
+ :format="field.format"
333
+ :locale="field.locale"
334
+ :min="0"
335
+ >
336
+ <NumberInputGroup>
337
+ <NumberInputDecrement aria-label="Decrease">
338
+ <MinusIcon aria-hidden="true" />
339
+ </NumberInputDecrement>
340
+ <NumberInputControl />
341
+ <NumberInputIncrement aria-label="Increase">
342
+ <PlusIcon aria-hidden="true" />
343
+ </NumberInputIncrement>
344
+ </NumberInputGroup>
345
+ </NumberInput>
346
+ <FieldDescription>Formatted for {{ field.locale }}.</FieldDescription>
347
+ </Field>
348
+ </div>
349
+ </template>
350
+ ```
351
+
352
+ Edit Preis using a comma for decimals, or step Budget to see Indian digit grouping. The displayed and accepted formats follow each field's locale.
353
+
354
+ ## Mouse Wheel
355
+
356
+ Set `wheel` to step with the mouse wheel while the input is focused. It is off by default.
357
+
358
+ ```vue title="wheel.vue"
359
+ <script setup lang="ts">
360
+ import { MinusIcon, PlusIcon } from "@lucide/vue"
361
+ import { Field, FieldDescription, FieldLabel } from "@ui-sdk/vue/field"
362
+ import {
363
+ NumberInput,
364
+ NumberInputControl,
365
+ NumberInputDecrement,
366
+ NumberInputGroup,
367
+ NumberInputIncrement,
368
+ } from "@ui-sdk/vue/number-input"
369
+ </script>
370
+
371
+ <template>
372
+ <Field>
373
+ <FieldLabel>Font size</FieldLabel>
374
+ <NumberInput :default-value="16" :min="8" :max="72" wheel>
375
+ <NumberInputGroup>
376
+ <NumberInputDecrement aria-label="Decrease">
377
+ <MinusIcon aria-hidden="true" />
378
+ </NumberInputDecrement>
379
+ <NumberInputControl />
380
+ <NumberInputIncrement aria-label="Increase">
381
+ <PlusIcon aria-hidden="true" />
382
+ </NumberInputIncrement>
383
+ </NumberInputGroup>
384
+ </NumberInput>
385
+ <FieldDescription>Focus the input, then scroll over it.</FieldDescription>
386
+ </Field>
387
+ </template>
388
+ ```
389
+
390
+ Focus Font size and scroll over it to change the value. Move focus away and scroll again; the value stays unchanged.
391
+
392
+ ## Scrub Area
393
+
394
+ `NumberInputScrubArea` changes the value while you drag it. The handle can be any element inside the number input: the label, as in the first example, or a letter or icon inside the group, as in a design tool. Right and up increase the value. `orientation` chooses an axis, and `pixels-per-step` controls how far the pointer moves per step. Shift and Alt (Option) use the large and small increments.
395
+
396
+ ```vue title="scrub.vue"
397
+ <script setup lang="ts">
398
+ import { MoveHorizontalIcon } from "@lucide/vue"
399
+ import {
400
+ NumberInput,
401
+ NumberInputControl,
402
+ NumberInputGroup,
403
+ NumberInputScrubArea,
404
+ NumberInputScrubAreaCursor,
405
+ } from "@ui-sdk/vue/number-input"
406
+ import { useId } from "vue"
407
+ import { useLog } from "./log"
408
+
409
+ const fields = [
410
+ { label: "X position", handle: "X", defaultValue: 120 },
411
+ { label: "Y position", handle: "Y", defaultValue: 48 },
412
+ { label: "Width", handle: "W", defaultValue: 320, min: 0 },
413
+ { label: "Height", handle: "H", defaultValue: 240, min: 0 },
414
+ ]
415
+
416
+ const log = useLog()
417
+ const title = useId()
418
+ </script>
419
+
420
+ <template>
421
+ <div data-slot="card" role="group" :aria-labelledby="title">
422
+ <h3 :id="title">Frame</h3>
423
+ <div data-slot="grid">
424
+ <NumberInput
425
+ v-for="field in fields"
426
+ :key="field.label"
427
+ :default-value="field.defaultValue"
428
+ :min="field.min"
429
+ @value-commit="(value) => log(`${field.label} ${value ?? 'empty'}`)"
430
+ >
431
+ <NumberInputGroup>
432
+ <NumberInputScrubArea :pixels-per-step="1">
433
+ <span aria-hidden="true">{{ field.handle }}</span>
434
+ <NumberInputScrubAreaCursor>
435
+ <MoveHorizontalIcon aria-hidden="true" />
436
+ </NumberInputScrubAreaCursor>
437
+ </NumberInputScrubArea>
438
+ <NumberInputControl :aria-label="field.label" />
439
+ </NumberInputGroup>
440
+ </NumberInput>
441
+ </div>
442
+ </div>
443
+ </template>
444
+ ```
445
+
446
+ Drag the X, Y, W or H letter sideways to change that value. Hold Shift for larger steps or Alt (Option) for smaller ones. The console logs each value when the drag ends.
447
+
448
+ Where pointer lock is available, the drag can continue past the edge of the screen. `NumberInputScrubAreaCursor` draws a replacement cursor while it is locked. The cursor is placed in the document body with an inline translation; center your icon with negative margins.
449
+
450
+ To place a scrub area outside its number input, such as on an icon in a toolbar, pass the same [controller](#controller) to both. More than one scrub area can control the same field.
451
+
452
+ ## Disabled
453
+
454
+ Set `disabled` on the component or its enclosing fieldset to prevent focus, changes, and form submission.
455
+
456
+ ```vue
457
+ <Field>
458
+ <FieldLabel>Quantity</FieldLabel>
459
+ <NumberInput :default-value="3" disabled>
460
+ <NumberInputGroup>
461
+ <NumberInputDecrement aria-label="Decrease">−</NumberInputDecrement>
462
+ <NumberInputControl />
463
+ <NumberInputIncrement aria-label="Increase">+</NumberInputIncrement>
464
+ </NumberInputGroup>
465
+ </NumberInput>
466
+ <FieldDescription>Sold out. You can't change the quantity.</FieldDescription>
467
+ </Field>
468
+ ```
469
+
470
+ Set `disabled` on one step button to turn off only that direction. The other button still steps.
471
+
472
+ ## Read-Only
473
+
474
+ Set `read-only` to keep the value focusable and included in form data while preventing edits and steps.
475
+
476
+ ```vue
477
+ <Field>
478
+ <FieldLabel>Seats included</FieldLabel>
479
+ <NumberInput :default-value="5" read-only>
480
+ <NumberInputGroup>
481
+ <NumberInputDecrement aria-label="Decrease">−</NumberInputDecrement>
482
+ <NumberInputControl />
483
+ <NumberInputIncrement aria-label="Increase">+</NumberInputIncrement>
484
+ </NumberInputGroup>
485
+ </NumberInput>
486
+ <FieldDescription>Set by your plan.</FieldDescription>
487
+ </Field>
488
+ ```
489
+
490
+ ## Validation
491
+
492
+ Use `required` to block an empty value. Field associates its error with the input and marks it invalid after an unsuccessful submit. Here, choosing **Continue** while Age is empty shows "Enter your age."
493
+
494
+ ```vue
495
+ <form>
496
+ <Field>
497
+ <FieldLabel>Age</FieldLabel>
498
+ <NumberInput name="age" required :min="18" :max="120">
499
+ <NumberInputGroup>
500
+ <NumberInputDecrement aria-label="Decrease">−</NumberInputDecrement>
501
+ <NumberInputControl />
502
+ <NumberInputIncrement aria-label="Increase">+</NumberInputIncrement>
503
+ </NumberInputGroup>
504
+ </NumberInput>
505
+ <FieldError match="valueMissing">Enter your age.</FieldError>
506
+ </Field>
507
+ <button type="submit">Continue</button>
508
+ </form>
509
+ ```
510
+
511
+ ## Controlled
512
+
513
+ Bind `v-model:value`, and listen to `@value-change` for the reason. `@value-change` reports valid changes while an interaction is in progress. `@value-commit` runs when typing is committed, a step key or button is released, or a scrub ends. Use the commit event for work that should happen after the interaction.
514
+
515
+ ```vue title="controlled.vue"
516
+ <script setup lang="ts">
517
+ import { MinusIcon, PlusIcon } from "@lucide/vue"
518
+ import type { NumberInputValueChangeReason } from "@ui-sdk/core/number-input"
519
+ import { Field, FieldLabel } from "@ui-sdk/vue/field"
520
+ import {
521
+ NumberInput,
522
+ NumberInputControl,
523
+ NumberInputDecrement,
524
+ NumberInputGroup,
525
+ NumberInputIncrement,
526
+ } from "@ui-sdk/vue/number-input"
527
+ import { ref } from "vue"
528
+ import { useLog } from "./log"
529
+
530
+ const log = useLog()
531
+ const value = ref<number | null>(4)
532
+
533
+ function onValueChange(
534
+ next: number | null,
535
+ details: { reason: NumberInputValueChangeReason }
536
+ ) {
537
+ log(`Value ${next ?? "empty"} (${details.reason})`)
538
+ }
539
+
540
+ function onValueCommit(
541
+ next: number | null,
542
+ details: { reason: NumberInputValueChangeReason }
543
+ ) {
544
+ log(`Committed ${next ?? "empty"} (${details.reason})`)
545
+ }
546
+ </script>
547
+
548
+ <template>
549
+ <div data-slot="stack">
550
+ <div data-slot="controls">
551
+ <button type="button" @click="value = 4">Reset to 4</button>
552
+ <button type="button" @click="value = null">Clear</button>
553
+ </div>
554
+ <Field>
555
+ <FieldLabel>Servings</FieldLabel>
556
+ <NumberInput
557
+ v-model:value="value"
558
+ :min="1"
559
+ :max="12"
560
+ @value-change="onValueChange"
561
+ @value-commit="onValueCommit"
562
+ >
563
+ <NumberInputGroup>
564
+ <NumberInputDecrement aria-label="Decrease">
565
+ <MinusIcon aria-hidden="true" />
566
+ </NumberInputDecrement>
567
+ <NumberInputControl />
568
+ <NumberInputIncrement aria-label="Increase">
569
+ <PlusIcon aria-hidden="true" />
570
+ </NumberInputIncrement>
571
+ </NumberInputGroup>
572
+ </NumberInput>
573
+ </Field>
574
+ </div>
575
+ </template>
576
+ ```
577
+
578
+ Hold a Servings step button. The console logs each value as it changes, then one Committed line when you let go. Clear sets the value to null, and Reset to 4 restores it.
579
+
580
+ See [State and Events](../state-and-events.md) for the shared state conventions and [Reasons](#reasons) for the events specific to Number Input.
581
+
582
+ ## Controller
583
+
584
+ Create a `createNumberInputController()` and pass it as `controller` to change or focus the input from other controls. `increment()` and `decrement()` step the value; pass `{ large: true }` for a large step. `setValue()`, `getValue()`, and `focus()` cover direct updates and inspection.
585
+
586
+ ```vue title="controller.vue"
587
+ <script setup lang="ts">
588
+ import { MinusIcon, PlusIcon } from "@lucide/vue"
589
+ import { Field, FieldLabel } from "@ui-sdk/vue/field"
590
+ import {
591
+ createNumberInputController,
592
+ NumberInput,
593
+ NumberInputControl,
594
+ NumberInputDecrement,
595
+ NumberInputGroup,
596
+ NumberInputIncrement,
597
+ } from "@ui-sdk/vue/number-input"
598
+ import { useLog } from "./log"
599
+
600
+ const log = useLog()
601
+ const zoom = createNumberInputController()
602
+ </script>
603
+
604
+ <template>
605
+ <div data-slot="stack">
606
+ <div data-slot="controls">
607
+ <button type="button" @click="zoom.decrement({ large: true })">
608
+ Zoom Out
609
+ </button>
610
+ <button type="button" @click="zoom.increment({ large: true })">
611
+ Zoom In
612
+ </button>
613
+ <button type="button" @click="zoom.setValue(100)">Actual Size</button>
614
+ <button type="button" @click="log(`Zoom is ${zoom.getValue()}%`)">
615
+ Read
616
+ </button>
617
+ <button type="button" @click="zoom.focus()">Focus</button>
618
+ </div>
619
+ <Field>
620
+ <FieldLabel>Zoom</FieldLabel>
621
+ <NumberInput
622
+ :default-value="100"
623
+ :min="10"
624
+ :max="400"
625
+ :step="10"
626
+ :format="{ style: 'unit', unit: 'percent' }"
627
+ :controller="zoom"
628
+ @value-change="
629
+ (value, details) =>
630
+ log(`Zoom ${value ?? 'empty'}% (${details.reason})`)
631
+ "
632
+ >
633
+ <NumberInputGroup>
634
+ <NumberInputDecrement aria-label="Decrease">
635
+ <MinusIcon aria-hidden="true" />
636
+ </NumberInputDecrement>
637
+ <NumberInputControl />
638
+ <NumberInputIncrement aria-label="Increase">
639
+ <PlusIcon aria-hidden="true" />
640
+ </NumberInputIncrement>
641
+ </NumberInputGroup>
642
+ </NumberInput>
643
+ </Field>
644
+ </div>
645
+ </template>
646
+ ```
647
+
648
+ Press Zoom In and Zoom Out to move by 100%, then Actual Size to restore 100%. Read logs the current value, and Focus moves into the field.
649
+
650
+ [Controllers](../controllers.md) covers creating and sharing a controller.
651
+
652
+ ## Form
653
+
654
+ A hidden input submits the plain numeric value under `name`. Formatting does not change form data: a displayed amount of $4.50 still submits `4.5`. Empty values submit an empty string.
655
+
656
+ ```vue title="form.vue"
657
+ <script setup lang="ts">
658
+ import { MinusIcon, PlusIcon } from "@lucide/vue"
659
+ import { Field, FieldLabel } from "@ui-sdk/vue/field"
660
+ import {
661
+ NumberInput,
662
+ NumberInputControl,
663
+ NumberInputDecrement,
664
+ NumberInputGroup,
665
+ NumberInputIncrement,
666
+ } from "@ui-sdk/vue/number-input"
667
+ import { useId } from "vue"
668
+ import { useLog } from "./log"
669
+
670
+ const log = useLog()
671
+ const form = useId()
672
+
673
+ function onSubmit(event: Event) {
674
+ const data = [...new FormData(event.currentTarget as HTMLFormElement)].map(
675
+ ([name, value]) => `${name}=${value}`
676
+ )
677
+ log(`Submitted ${data.join(", ")}`)
678
+ }
679
+ </script>
680
+
681
+ <template>
682
+ <div data-slot="stack">
683
+ <form :id="form" data-slot="stack" @submit.prevent="onSubmit">
684
+ <Field>
685
+ <FieldLabel>Quantity</FieldLabel>
686
+ <NumberInput name="quantity" :default-value="2" :min="1">
687
+ <NumberInputGroup>
688
+ <NumberInputDecrement aria-label="Decrease">
689
+ <MinusIcon aria-hidden="true" />
690
+ </NumberInputDecrement>
691
+ <NumberInputControl />
692
+ <NumberInputIncrement aria-label="Increase">
693
+ <PlusIcon aria-hidden="true" />
694
+ </NumberInputIncrement>
695
+ </NumberInputGroup>
696
+ </NumberInput>
697
+ </Field>
698
+ <Field>
699
+ <FieldLabel>Tip</FieldLabel>
700
+ <NumberInput
701
+ name="tip"
702
+ :default-value="4.5"
703
+ :min="0"
704
+ :step="0.5"
705
+ :format="{ style: 'currency', currency: 'USD' }"
706
+ >
707
+ <NumberInputGroup>
708
+ <NumberInputDecrement aria-label="Decrease">
709
+ <MinusIcon aria-hidden="true" />
710
+ </NumberInputDecrement>
711
+ <NumberInputControl />
712
+ <NumberInputIncrement aria-label="Increase">
713
+ <PlusIcon aria-hidden="true" />
714
+ </NumberInputIncrement>
715
+ </NumberInputGroup>
716
+ </NumberInput>
717
+ </Field>
718
+ </form>
719
+ <Field>
720
+ <FieldLabel>Gift cards</FieldLabel>
721
+ <NumberInput name="gift-cards" :form="form" :default-value="0" :min="0">
722
+ <NumberInputGroup>
723
+ <NumberInputDecrement aria-label="Decrease">
724
+ <MinusIcon aria-hidden="true" />
725
+ </NumberInputDecrement>
726
+ <NumberInputControl />
727
+ <NumberInputIncrement aria-label="Increase">
728
+ <PlusIcon aria-hidden="true" />
729
+ </NumberInputIncrement>
730
+ </NumberInputGroup>
731
+ </NumberInput>
732
+ </Field>
733
+ <div data-slot="row">
734
+ <button type="reset" :form="form">Reset</button>
735
+ <button type="submit" :form="form" data-variant="solid">Save</button>
736
+ </div>
737
+ </div>
738
+ </template>
739
+ ```
740
+
741
+ Change Quantity or Tip and press Save: the console logs the plain numeric values. Gift cards belongs to the same form through its form ID. Reset restores the defaults.
742
+
743
+ Set `form` to associate the input with a form elsewhere in the page. A form reset restores the default value and reports the `reset` reason.
744
+
745
+ ## Custom Rendering
746
+
747
+ Every part takes a `render` slot, which receives the props to bind and the part's state, and the default slot receives the state. Here the decrement button adds a tooltip, and the increment button shows Max once the value reaches its bound.
748
+
749
+ ```vue title="render.vue"
750
+ <script setup lang="ts">
751
+ import { MinusIcon, PlusIcon } from "@lucide/vue"
752
+ import { Field, FieldLabel } from "@ui-sdk/vue/field"
753
+ import {
754
+ NumberInput,
755
+ NumberInputControl,
756
+ NumberInputDecrement,
757
+ NumberInputGroup,
758
+ NumberInputIncrement,
759
+ } from "@ui-sdk/vue/number-input"
760
+ </script>
761
+
762
+ <template>
763
+ <Field>
764
+ <FieldLabel>Temperature</FieldLabel>
765
+ <NumberInput :default-value="-2" :min="-20" :max="40" :format="{ style: 'unit', unit: 'celsius' }">
766
+ <NumberInputGroup>
767
+ <NumberInputDecrement aria-label="Colder">
768
+ <template #render="{ props, state }">
769
+ <button v-bind="props" :title="state.atBound ? 'As cold as it goes' : 'Colder'">
770
+ <MinusIcon aria-hidden="true" />
771
+ </button>
772
+ </template>
773
+ </NumberInputDecrement>
774
+ <NumberInputControl />
775
+ <NumberInputIncrement v-slot="{ state }" aria-label="Warmer">
776
+ <span v-if="state.atBound">Max</span>
777
+ <PlusIcon v-else aria-hidden="true" />
778
+ </NumberInputIncrement>
779
+ </NumberInputGroup>
780
+ </NumberInput>
781
+ </Field>
782
+ </template>
783
+ ```
784
+
785
+ Press End in Temperature to jump to 40°C. The increment button reads Max; hover the decrement button to see its tooltip.
786
+
787
+ Each part's state is listed under [State](#state).
788
+
789
+ ## Styling
790
+
791
+ Style the group as the field's box, and the input and step buttons inside it. `data-disabled` on a step button also means it has reached its bound, and `data-scrubbing` marks every part while a drag changes the value. Inside Field, the native input receives validation attributes such as `data-invalid`. Use logical spacing so the layout follows the surrounding direction.
792
+
793
+ Each part has a `data-slot`, such as `number-input-group`, and its state attributes are listed under [Data Attributes](#data-attributes).
794
+
795
+ ## Data Attributes
796
+
797
+ ### NumberInput
798
+ `[data-slot="number-input"]`
799
+
800
+ - `data-disabled`: Present when disabled, by its own prop or a `<fieldset>`.
801
+ - `data-readonly`: Present when read-only.
802
+ - `data-required`: Present when required.
803
+ - `data-scrubbing`: Present while a drag on the scrub area changes the value.
804
+
805
+ ### NumberInputScrubArea
806
+ `[data-slot="number-input-scrub-area"]`
807
+
808
+ - `data-disabled`: Present when disabled, by its own prop or a `<fieldset>`.
809
+ - `data-readonly`: Present when read-only.
810
+ - `data-required`: Present when required.
811
+ - `data-orientation` (`horizontal`, `vertical`): Which way to drag.
812
+ - `data-scrubbing`: Present while a drag on the scrub area changes the value.
813
+
814
+ ### NumberInputScrubAreaCursor
815
+ `[data-slot="number-input-scrub-area-cursor"]`
816
+
817
+ - `data-disabled`: Present when disabled, by its own prop or a `<fieldset>`.
818
+ - `data-readonly`: Present when read-only.
819
+ - `data-required`: Present when required.
820
+ - `data-scrubbing`: Present while a drag on the scrub area changes the value.
821
+
822
+ ### NumberInputGroup
823
+ `[data-slot="number-input-group"]`
824
+
825
+ - `data-disabled`: Present when disabled, by its own prop or a `<fieldset>`.
826
+ - `data-readonly`: Present when read-only.
827
+ - `data-required`: Present when required.
828
+ - `data-scrubbing`: Present while a drag on the scrub area changes the value.
829
+
830
+ ### NumberInputDecrement
831
+ `[data-slot="number-input-decrement"]`
832
+
833
+ - `data-disabled`: Present when the button can't step: it or the field is disabled, the field is read-only, or the value is at `min`.
834
+ - `data-readonly`: Present when read-only.
835
+ - `data-required`: Present when required.
836
+ - `data-at-bound`
837
+ - `data-scrubbing`: Present while a drag on the scrub area changes the value.
838
+
839
+ ### NumberInputControl
840
+ `[data-slot="number-input-control"]`
841
+
842
+ - `data-disabled`: Present when disabled, by its own prop or a `<fieldset>`.
843
+ - `data-readonly`: Present when read-only.
844
+ - `data-required`: Present when required.
845
+ - `data-scrubbing`: Present while a drag on the scrub area changes the value.
846
+
847
+ ### NumberInputIncrement
848
+ `[data-slot="number-input-increment"]`
849
+
850
+ - `data-disabled`: Present when the button can't step: it or the field is disabled, the field is read-only, or the value is at `max`.
851
+ - `data-readonly`: Present when read-only.
852
+ - `data-required`: Present when required.
853
+ - `data-scrubbing`: Present while a drag on the scrub area changes the value.
854
+
855
+ ## API Reference
856
+
857
+ Props are the same as below, and callbacks are events.
858
+
859
+ ### NumberInput
860
+
861
+ - `value?` (`number | null`): The value, or null for an empty field. Pass it to control the field.
862
+ - `defaultValue?` (`number | null`): The value at first, when uncontrolled. A form reset returns to it.
863
+ - `@value-change` (`((value: number | null, details: ChangeDetails<NumberInputValueChangeReason>) => void)`): Runs when the value changes: as a typed number becomes valid, and on every step. `details.cancel()` stops it.
864
+ - `@value-commit` (`((value: number | null, details: CommitDetails<NumberInputValueChangeReason>) => void)`): Runs once an interaction that changed the value ends: typing is committed, a key or a button is released, or a scrub ends. For saving.
865
+ - `min?` (`number`): The lowest value. Typed values below it are raised to it when committed.
866
+ - `max?` (`number`): The highest value. Typed values above it are lowered to it when committed.
867
+ - `step?` (`number`): How far one step moves. Committed values snap to steps from `min`, or from 0 without one.
868
+ - `largeStep?` (`number`): How far Page Up, Page Down, and Shift with an arrow key, a button, the wheel or a scrub move.
869
+ - `smallStep?` (`number`): How far Alt (Option on a Mac) with an arrow key, the wheel or a scrub moves, for fine changes. Values it reaches snap to it rather than to `step`.
870
+ - `format?` (`Intl.NumberFormatOptions`): How the value shows: `Intl.NumberFormat` options, like `{ style: "currency", currency: "USD" }`. Typing accepts the same format in the locale, and percents are fractions: 50% is 0.5.
871
+ - `locale?` (`string`): The locale for formatting and reading typed numbers. Defaults to the page's `lang`, or the browser's language without one, once the page is interactive. Server markup uses English until then, so it never disagrees with the client.
872
+ - `wheel?` (`boolean`): Lets the mouse wheel step the value while the input has focus.
873
+ - `disabled?` (`boolean`): Disables it like a native control: it can't be focused or changed, and isn't submitted.
874
+ - `readOnly?` (`boolean`): Keeps it focusable and submitted, but stops changes.
875
+ - `required?` (`boolean`): Blocks form submission while it's empty, with the browser's own message.
876
+ - `name?` (`string`): The name it submits under. The number is submitted as is, like `1234.5`, never formatted.
877
+ - `form?` (`string`): The id of a form to belong to, when it isn't inside that form.
878
+ - `controller?` (`object`): Steps it from anywhere. Create one with `createNumberInputController()`.
879
+ - `debug?` (`boolean`): Logs every state change with its reason to the console, in development builds.
880
+
881
+ ### NumberInputScrubArea
882
+
883
+ - `orientation?` (`"horizontal" | "vertical"`): Which way to drag: right and up increase.
884
+ - `pixelsPerStep?` (`number`): How far the pointer moves for one step, in CSS pixels.
885
+ - `controller?` (`object`): Connects a scrub area outside the number input, like an icon in a toolbar, to the number input with this controller. Inside it, it connects on its own. Web components use `for="<number input id>"` instead.
886
+
887
+ ### NumberInputIncrement and NumberInputDecrement
888
+
889
+ - `disabled?` (`boolean`): Turns off this button alone. Pressing, clicking or holding it doesn't step.
890
+
891
+ ### State
892
+
893
+ What render functions, state-based class names and slots receive. Every part gets the field's state.
894
+
895
+ - `value` (`number | null`): The value, or null when empty.
896
+ - `disabled` (`boolean`): Whether it's disabled, by itself or by a `<fieldset>`.
897
+ - `readOnly` (`boolean`): Whether it's read-only: it stays focusable and submitted, but typing, steps and scrubs don't change it.
898
+ - `required` (`boolean`): Whether a form won't submit while it's empty.
899
+ - `scrubbing` (`boolean`): Whether a scrub is moving the value.
900
+
901
+ The buttons' state, `NumberInputButtonState`, says whether that button can step, and whether the value is at its bound, apart from a disabled field:
902
+
903
+ - `value` (`number | null`): The value, or null when empty.
904
+ - `disabled` (`boolean`): Whether it's disabled, by itself or by a `<fieldset>`. Whether the button can't step, because it or the field is disabled, the field is read-only, or the value is at its bound.
905
+ - `readOnly` (`boolean`): Whether it's read-only: it stays focusable and submitted, but typing, steps and scrubs don't change it.
906
+ - `required` (`boolean`): Whether a form won't submit while it's empty.
907
+ - `scrubbing` (`boolean`): Whether a scrub is moving the value.
908
+ - `atBound` (`boolean`): Whether the value is at the bound this button steps toward, like the maximum for the increment.
909
+
910
+ ### Reasons
911
+
912
+ `details.reason` says why the value changed.
913
+
914
+ - `input-change` (`Event`): Typing, pasting or dropping changed a text field's value; in a combobox it can also open or close it, or Enter keeps the typed text as the value.
915
+ - `input-commit` (`KeyboardEvent | FocusEvent`): Enter, or leaving a number input, committed what was typed: a number input parses, clamps and snaps it to the step, and an autocomplete closes its suggestions on it.
916
+ - `step-key` (`KeyboardEvent`): Arrow, Page Up, Page Down, Home or End stepped a slider or a number input.
917
+ - `increment-press` (`MouseEvent | PointerEvent`): A number input's increment button was pressed, or held.
918
+ - `decrement-press` (`MouseEvent | PointerEvent`): A number input's decrement button was pressed, or held.
919
+ - `wheel` (`WheelEvent`): The mouse wheel stepped a focused number input.
920
+ - `scrub` (`PointerEvent`): A drag on a number input's scrub area.
921
+ - `reset` (`none`): A form reset.
922
+ - `restore` (`none`): The browser restored state, like after going back, or a saved value was read back from storage.
923
+ - `imperative` (`none`): A controller or `api` call, or a property set on a web component.
924
+
925
+ ### Controller
926
+
927
+ Create one with `createNumberInputController()` and pass it as `controller`.
928
+
929
+ Every write method takes an optional `{ reason, event }`, runs the change callback like a press, and returns `false` when the change is canceled.
930
+
931
+ - `getValue()` (`() => number | null`): The value, or null when the field is empty.
932
+ - `setValue(value, options?)` (`(value: number | null, options?: NumberInputChangeOptions | undefined) => boolean`): Sets the value, as a user would. It's clamped and snapped to the step.
933
+ - `increment(options?)` (`(options?: (NumberInputChangeOptions & { large?: boolean | undefined; }) | undefined) => boolean`): Steps the value up, by `largeStep` with `{ large: true }`.
934
+ - `decrement(options?)` (`(options?: (NumberInputChangeOptions & { large?: boolean | undefined; }) | undefined) => boolean`): Steps the value down, by `largeStep` with `{ large: true }`.
935
+ - `focus()` (`() => void`): Moves focus to the input.
936
+
937
+ ### Events
938
+
939
+ Events get the new value first, then the details. `v-model` only updates when the change event wasn't canceled.
940
+
941
+ | Binding | On | Receives |
942
+ | --------------- | ------------- | --------------------------------------------------------------------------------- |
943
+ | `v-model:value` | `NumberInput` | The value, or null when empty |
944
+ | `@value-change` | `NumberInput` | `(value, details)`: the new value, or null when empty, and the [reason](#reasons) |
945
+ | `@value-commit` | `NumberInput` | `(value, details)`: the value once the interaction ends, and its reason |
946
+
947
+ ## Accessibility
948
+
949
+ Follows the keyboard model of the [WAI-ARIA spinbutton pattern](https://www.w3.org/WAI/ARIA/apg/patterns/spinbutton/) on a native text input, so ordinary text editing works too. Give the input a FieldLabel or `aria-label`, and name both step buttons. Each button points to the input with `aria-controls`.
950
+
951
+ ### Keyboard
952
+
953
+ | Input | Increment |
954
+ | --------------------------------------------------- | -------------------------------------------------- |
955
+ | ArrowUp, ArrowDown, or a step button | `step`, which defaults to 1. |
956
+ | Shift with an arrow or button; Page Up or Page Down | `large-step`, which defaults to ten steps. |
957
+ | Alt (Option) with an arrow key | `small-step`, which defaults to a tenth of a step. |
958
+ | Home or End | The minimum or maximum, when set. |
959
+
960
+ Enter commits typed text. The step buttons stay out of the Tab order, because the focused input gives the same steps through its arrow keys.
961
+
962
+ ### Tested Behavior
963
+
964
+ Every line below is an automated test.
965
+
966
+ **Keyboard**
967
+
968
+ - Starts with its default value, formatted.
969
+ - ArrowUp and ArrowDown step the value.
970
+ - Shift with an arrow key steps by the large step.
971
+ - Home and End go to the minimum and the maximum.
972
+ - Stepping stops at the bounds.
973
+ - Steps keep cents exact.
974
+ - The buttons aren't in the tab order.
975
+
976
+ **Typing**
977
+
978
+ - Typing a number changes the value.
979
+ - A typed value above the maximum is lowered when focus leaves.
980
+ - Typed text in the format is read and formatted when focus leaves.
981
+ - Typing sends change only once the text is committed.
982
+ - Letters can't be typed.
983
+ - Arrow keys step from what's typed.
984
+ - Text that isn't a number goes back to the value when focus leaves.
985
+ - The value commits when focus leaves.
986
+
987
+ **Buttons**
988
+
989
+ - The increment and decrement buttons step the value.
990
+ - A button at its bound is disabled and marked data-at-bound.
991
+ - Holding a button repeats the step.
992
+ - A press commits when the button is released.
993
+ - A disabled button is marked disabled.
994
+ - A disabled button doesn't step when clicked or held, and the other still does.
995
+ - <button disabled> inside a step button element stays disabled past a bound. Web components only.
996
+ - A button disabled while it's held stops repeating.
997
+
998
+ **State and forms**
999
+
1000
+ - Submits the number as is, not formatted.
1001
+ - A disabled field can't be focused or changed.
1002
+ - A read-only field can be focused, but not changed.
1003
+ - A required empty field blocks the form.
1004
+ - The mouse wheel does nothing unless turned on.
1005
+ - The mouse wheel steps a focused field when turned on.
1006
+ - A canceled change keeps the value.
1007
+ - A controlled field follows its value.
1008
+ - Reads and writes the locale's format.
1009
+
1010
+ Runs in React, Vue and web components.
1011
+
1012
+ Beyond the pattern:
1013
+
1014
+ - Page Up and Page Down step by the large step.
1015
+ - A form reset returns every field to its default.
1016
+ - A typed value snaps to the step when focus leaves.
1017
+ - Enter commits and formats what's typed.
1018
+ - Holding an arrow key commits once, when the key comes up.
1019
+ - A field with cents asks for a decimal keypad.
1020
+ - A scrub steps by distance, whatever the speed.
1021
+ - A scrub that doesn't move commits nothing.
1022
+
1023
+ Runs in React, Vue and web components.
1024
+
1025
+ Screen readers hear the same thing in each tested framework, recorded by a virtual screen reader:
1026
+
1027
+ - Announcements while moving to a number input with a keyboard.
1028
+
1029
+ Runs in React, Vue and web components.