Range Slider - 图1

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

PropTypeDefaultDescription
<Range> properties
initbooleantrueInitializes Range Slider
valuenumber
array
string
Range Slider value, must be array in case of dual range slider
minnumber
string
Minimum value
maxnumber
string
Maximum value
stepnumber
string
1Maximum value
labelbooleanfalseEnables additional label around range slider knob
dualbooleanfalseEnables dual range slider
verticalbooleanfalseEnables vertical range slider
verticalReversedbooleanfalseMakes vertical range slider reversed. (Only when vertical:true)
draggableBarbooleantrueWhen enabled it is also possible to interact with range slider (change value) on range bar click and swipe.
formatLabelfunction(value)Method must return formatted range knob label text. As an argument it receives label value
scalebooleanfalseEnables range slider scale
scaleStepsnumber5Number of scale steps
scaleSubStepsnumber0Number of scale sub steps (each step will be divided by this value)
formatScaleLabelfunction (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.
limitKnobPositionbooleanLimits knob position to the size of the range bar. By default enabled from iOS theme
disabledbooleanfalseDefines whether the range slider is disabled or not
idstringRange slider element ID attribute
inputbooleanfalseIf enabled, then it will render input type=”range” element inside as well
inputIdstringInput element ID attribute
namestringInput element “name” attribute

Range Slider Events

EventDescription
<Range> events
rangeChangeEvent will be triggered when Range Slider value has been changed
rangeChangedEvent will be triggered on slider knob release after value change

Range Slider Methods

EventDescription
<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);
  4. this.state = {
  5. priceMin: 200,
  6. priceMax: 400,
  7. }
  8. }
  9. render() {
  10. return (
  11. <Page>
  12. <Navbar title="Range Slider"></Navbar>
  13. <BlockTitle>Volume</BlockTitle>
  14. <List simpleList>
  15. <ListItem>
  16. <ListItemCell className="width-auto flex-shrink-0">
  17. <Icon ios="f7:speaker_fill" aurora="f7:speaker_fill" md="material:volume_mute"></Icon>
  18. </ListItemCell>
  19. <ListItemCell className="flex-shrink-3">
  20. <Range
  21. min={0}
  22. max={100}
  23. step={1}
  24. value={10}
  25. ></Range>
  26. </ListItemCell>
  27. <ListItemCell className="width-auto flex-shrink-0">
  28. <Icon ios="f7:speaker_3_fill" aurora="f7:speaker_3_fill" md="material:volume_up"></Icon>
  29. </ListItemCell>
  30. </ListItem>
  31. </List>
  32. <BlockTitle>Brightness</BlockTitle>
  33. <List simpleList>
  34. <ListItem>
  35. <ListItemCell className="width-auto flex-shrink-0">
  36. <Icon ios="f7:sun_min" aurora="f7:sun_min" md="material:brightness_low"></Icon>
  37. </ListItemCell>
  38. <ListItemCell className="flex-shrink-3">
  39. <Range
  40. min={0}
  41. max={100}
  42. step={1}
  43. value={50}
  44. label={true}
  45. color="orange"
  46. ></Range>
  47. </ListItemCell>
  48. <ListItemCell className="width-auto flex-shrink-0">
  49. <Icon ios="f7:sun_max" aurora="f7:sun_max" md="material:brightness_high"></Icon>
  50. </ListItemCell>
  51. </ListItem>
  52. </List>
  53. <BlockTitle className="display-flex justify-content-space-between">Price Filter <span>${this.state.priceMin} - ${this.state.priceMax}</span></BlockTitle>
  54. <List simpleList>
  55. <ListItem>
  56. <ListItemCell className="width-auto flex-shrink-0">
  57. <Icon ios="f7:money_dollar_round" aurora="f7:money_dollar_round" md="material:attach_money"></Icon>
  58. </ListItemCell>
  59. <ListItemCell className="flex-shrink-3">
  60. <Range
  61. min={0}
  62. max={500}
  63. step={1}
  64. value={[this.state.priceMin, this.state.priceMax]}
  65. label={true}
  66. dual={true}
  67. color="green"
  68. onRangeChange={this.onPriceChange.bind(this)}
  69. ></Range>
  70. </ListItemCell>
  71. <ListItemCell className="width-auto flex-shrink-0">
  72. <Icon ios="f7:money_dollar_round_fill" aurora="f7:money_dollar_round_fill" md="material:monetization_on"></Icon>
  73. </ListItemCell>
  74. </ListItem>
  75. </List>
  76. <BlockTitle>With Scale</BlockTitle>
  77. <Block strong>
  78. <Range
  79. min={0}
  80. max={100}
  81. label={true}
  82. step={5}
  83. value={25}
  84. scale={true}
  85. scaleSteps={5}
  86. scaleSubSteps={4}
  87. />
  88. </Block>
  89. <BlockTitle>Vertical</BlockTitle>
  90. <Block strong className="display-flex justify-content-center">
  91. <Range
  92. className="margin-right"
  93. style={{height: '160px'}}
  94. vertical={true}
  95. min={0}
  96. max={100}
  97. label={true}
  98. step={1}
  99. value={25}
  100. />
  101. <Range
  102. className="margin-horizontal"
  103. style={{height: '160px'}}
  104. vertical={true}
  105. min={0}
  106. max={100}
  107. label={true}
  108. step={1}
  109. value={50}
  110. />
  111. <Range
  112. className="margin-horizontal"
  113. style={{height: '160px'}}
  114. vertical={true}
  115. min={0}
  116. max={100}
  117. label={true}
  118. step={1}
  119. value={75}
  120. />
  121. <Range
  122. className="margin-left"
  123. style={{height: '160px'}}
  124. dual={true}
  125. vertical={true}
  126. min={0}
  127. max={100}
  128. label={true}
  129. step={1}
  130. value={[25, 75]}
  131. />
  132. </Block>
  133. <BlockTitle>Vertical Reversed</BlockTitle>
  134. <Block strong className="display-flex justify-content-center">
  135. <Range
  136. className="margin-right"
  137. color="red"
  138. style={{height: '160px'}}
  139. vertical={true}
  140. verticalReversed={true}
  141. min={0}
  142. max={100}
  143. label={true}
  144. step={1}
  145. value={25}
  146. />
  147. <Range
  148. className="margin-horizontal"
  149. color="red"
  150. style={{height: '160px'}}
  151. vertical={true}
  152. verticalReversed={true}
  153. min={0}
  154. max={100}
  155. label={true}
  156. step={1}
  157. value={50}
  158. />
  159. <Range
  160. className="margin-horizontal"
  161. color="red"
  162. style={{height: '160px'}}
  163. vertical={true}
  164. verticalReversed={true}
  165. min={0}
  166. max={100}
  167. label={true}
  168. step={1}
  169. value={75}
  170. />
  171. <Range
  172. className="margin-left"
  173. color="red"
  174. style={{height: '160px'}}
  175. dual={true}
  176. vertical={true}
  177. verticalReversed={true}
  178. min={0}
  179. max={100}
  180. label={true}
  181. step={1}
  182. value={[25, 75]}
  183. />
  184. </Block>
  185. </Page>
  186. )
  187. }
  188. onPriceChange(values) {
  189. this.setState({
  190. priceMin: values[0],
  191. priceMax: values[1],
  192. });
  193. }
  194. }

← Radio

Searchbar →