
Range Slider React Component
Range Slider React component represents Range Slider component.
Range Slider Components
There are following components included:
Range/F7Range
Range Slider Properties
| Prop | Type | Default | Description |
|---|---|---|---|
| <Range> properties | |||
| --- | --- | --- | --- |
| init | boolean | true | Initializes Range Slider |
| value | number array string | Range Slider value, must be array in case of dual range slider | |
| min | number string | Minimum value | |
| max | number string | Maximum value | |
| step | number string | 1 | Maximum value |
| label | boolean | false | Enables additional label around range slider knob |
| dual | boolean | false | Enables dual range slider |
| vertical | boolean | false | Enables vertical range slider |
| verticalReversed | boolean | false | Makes vertical range slider reversed. (Only when vertical:true) |
| draggableBar | boolean | true | When enabled it is also possible to interact with range slider (change value) on range bar click and swipe. |
| formatLabel | function(value) | Method must return formatted range knob label text. As an argument it receives label value | |
| scale | boolean | false | Enables range slider scale |
| scaleSteps | number | 5 | Number of scale steps |
| scaleSubSteps | number | 0 | Number of scale sub steps (each step will be divided by this value) |
| formatScaleLabel | function (value) | Method must return formatted scale value. As an argument it receives currect scale step value. This method will be called as for each scale step. | |
| limitKnobPosition | boolean | Limits knob position to the size of the range bar. By default enabled from iOS theme | |
| disabled | boolean | false | Defines whether the range slider is disabled or not |
| id | string | Range slider element ID attribute | |
| input | boolean | false | If enabled, then it will render input type=”range” element inside as well |
| inputId | string | Input element ID attribute | |
| name | string | Input element “name” attribute |
Range Slider Events
| Event | Description |
|---|---|
| <Range> events | |
| --- | --- |
| rangeChange | Event will be triggered when Range Slider value has been changed |
| rangeChanged | Event will be triggered on slider knob release after value change |
Range Slider Methods
| Event | Description |
|---|---|
| <Range> methods | |
| --- | --- |
| .setValue(newValue) | Set new range slider value |
| .getValue() | Returns range slider value |
Examples
1. export default class extends React.Component {
2. constructor(props) {
3. super(props);
5. this.state = {
6. priceMin: 200,
7. priceMax: 400,
8. }
9. }
10. render() {
11. return (
12. <Page>
13. <Navbar title="Range Slider"></Navbar>
15. <BlockTitle>Volume</BlockTitle>
16. <List simpleList>
17. <ListItem>
18. <ListItemCell className="width-auto flex-shrink-0">
19. <Icon ios="f7:speaker_fill" aurora="f7:speaker_fill" md="material:volume_mute"></Icon>
20. </ListItemCell>
21. <ListItemCell className="flex-shrink-3">
22. <Range
23. min={0}
24. max={100}
25. step={1}
26. value={10}
27. ></Range>
28. </ListItemCell>
29. <ListItemCell className="width-auto flex-shrink-0">
30. <Icon ios="f7:speaker_3_fill" aurora="f7:speaker_3_fill" md="material:volume_up"></Icon>
31. </ListItemCell>
32. </ListItem>
33. </List>
35. <BlockTitle>Brightness</BlockTitle>
36. <List simpleList>
37. <ListItem>
38. <ListItemCell className="width-auto flex-shrink-0">
39. <Icon ios="f7:sun_min" aurora="f7:sun_min" md="material:brightness_low"></Icon>
40. </ListItemCell>
41. <ListItemCell className="flex-shrink-3">
42. <Range
43. min={0}
44. max={100}
45. step={1}
46. value={50}
47. label={true}
48. color="orange"
49. ></Range>
50. </ListItemCell>
51. <ListItemCell className="width-auto flex-shrink-0">
52. <Icon ios="f7:sun_max" aurora="f7:sun_max" md="material:brightness_high"></Icon>
53. </ListItemCell>
54. </ListItem>
55. </List>
57. <BlockTitle className="display-flex justify-content-space-between">Price Filter <span>${this.state.priceMin} - ${this.state.priceMax}</span></BlockTitle>
58. <List simpleList>
59. <ListItem>
60. <ListItemCell className="width-auto flex-shrink-0">
61. <Icon ios="f7:money_dollar_round" aurora="f7:money_dollar_round" md="material:attach_money"></Icon>
62. </ListItemCell>
63. <ListItemCell className="flex-shrink-3">
64. <Range
65. min={0}
66. max={500}
67. step={1}
68. value={[this.state.priceMin, this.state.priceMax]}
69. label={true}
70. dual={true}
71. color="green"
72. onRangeChange={this.onPriceChange.bind(this)}
73. ></Range>
74. </ListItemCell>
75. <ListItemCell className="width-auto flex-shrink-0">
76. <Icon ios="f7:money_dollar_round_fill" aurora="f7:money_dollar_round_fill" md="material:monetization_on"></Icon>
77. </ListItemCell>
78. </ListItem>
79. </List>
81. <BlockTitle>With Scale</BlockTitle>
82. <Block strong>
83. <Range
84. min={0}
85. max={100}
86. label={true}
87. step={5}
88. value={25}
89. scale={true}
90. scaleSteps={5}
91. scaleSubSteps={4}
92. />
93. </Block>
95. <BlockTitle>Vertical</BlockTitle>
96. <Block strong className="display-flex justify-content-center">
97. <Range
98. className="margin-right"
99. style={{height: '160px'}}
100. vertical={true}
101. min={0}
102. max={100}
103. label={true}
104. step={1}
105. value={25}
106. />
107. <Range
108. className="margin-horizontal"
109. style={{height: '160px'}}
110. vertical={true}
111. min={0}
112. max={100}
113. label={true}
114. step={1}
115. value={50}
116. />
117. <Range
118. className="margin-horizontal"
119. style={{height: '160px'}}
120. vertical={true}
121. min={0}
122. max={100}
123. label={true}
124. step={1}
125. value={75}
126. />
127. <Range
128. className="margin-left"
129. style={{height: '160px'}}
130. dual={true}
131. vertical={true}
132. min={0}
133. max={100}
134. label={true}
135. step={1}
136. value={[25, 75]}
137. />
138. </Block>
140. <BlockTitle>Vertical Reversed</BlockTitle>
141. <Block strong className="display-flex justify-content-center">
142. <Range
143. className="margin-right"
144. color="red"
145. style={{height: '160px'}}
146. vertical={true}
147. verticalReversed={true}
148. min={0}
149. max={100}
150. label={true}
151. step={1}
152. value={25}
153. />
154. <Range
155. className="margin-horizontal"
156. color="red"
157. style={{height: '160px'}}
158. vertical={true}
159. verticalReversed={true}
160. min={0}
161. max={100}
162. label={true}
163. step={1}
164. value={50}
165. />
166. <Range
167. className="margin-horizontal"
168. color="red"
169. style={{height: '160px'}}
170. vertical={true}
171. verticalReversed={true}
172. min={0}
173. max={100}
174. label={true}
175. step={1}
176. value={75}
177. />
178. <Range
179. className="margin-left"
180. color="red"
181. style={{height: '160px'}}
182. dual={true}
183. vertical={true}
184. verticalReversed={true}
185. min={0}
186. max={100}
187. label={true}
188. step={1}
189. value={[25, 75]}
190. />
191. </Block>
192. </Page>
193. )
194. }
195. onPriceChange(values) {
196. this.setState({
197. priceMin: values[0],
198. priceMax: values[1],
199. });
200. }
201. }
