Range Slider - 图1

Range Slider Svelte Component

Range Slider Svelte component represents Range Slider component.

Range Slider Components

There are following components included:

  • Range

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

← Radio

Searchbar →