-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
README.md
106 lines (69 loc) · 2.36 KB
/
README.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# NumberControl
<div class="callout callout-alert">
This feature is still experimental. “Experimental” means this is an early implementation subject to drastic and breaking changes.
</div>
NumberControl is an enhanced HTML [`input[type="number]`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number) element.
## Usage
```jsx
import { __experimentalNumberControl as NumberControl } from '@wordpress/components';
const Example = () => {
const [ value, setValue ] = useState( 10 );
return (
<NumberControl
isShiftStepEnabled={ true }
onChange={ setValue }
shiftStep={ 10 }
value={ value }
/>
);
};
```
## Props
### dragDirection
Determines the drag axis to increment/decrement the value.
Directions: `n` | `e` | `s` | `w`
- Type: `String`
- Required: No
- Default: `n`
### dragThreshold
If `isDragEnabled` is true, this controls the amount of `px` to have been dragged before the value changes.
- Type: `Number`
- Required: No
- Default: `10`
### hideHTMLArrows
If true, the default `input` HTML arrows will be hidden.
- Type: `Boolean`
- Required: No
- Default: `false`
### isDragEnabled
If true, enables mouse drag gesture to increment/decrement the number value. Holding `SHIFT` while dragging will increase the value by the `shiftStep`.
- Type: `Boolean`
- Required: No
### isShiftStepEnabled
If true, pressing `UP` or `DOWN` along with the `SHIFT` key will increment the value by the `shiftStep` value.
- Type: `Boolean`
- Required: No
- Default: `true`
### label
If this property is added, a label will be generated using label property as the content.
- Type: `String`
- Required: No
### labelPosition
The position of the label (`top`, `side`, `bottom`, or `edge`).
- Type: `String`
- Required: No
### required
If `true` enforces a valid number within the control's min/max range. If `false` allows an empty string as a valid value.
- Type: `Boolean`
- Required: No
- Default: `false`
### shiftStep
Amount to increment by when the `SHIFT` key is held down. This shift value is a multiplier to the `step` value. For example, if the `step` value is `5`, and `shiftStep` is `10`, each jump would increment/decrement by `50`.
- Type: `Number`
- Required: No
- Default: `10`
### step
Amount to increment by when incrementing/decrementing.
- Type: `Number`
- Required: No
- Default: `1`