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
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
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

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:volume_mute_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:volume_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:circle" 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:circle_half" 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:circle" md="material:brightness_low"></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:circle_half" md="material:brightness_high"></Icon>
  73. </ListItemCell>
  74. </ListItem>
  75. </List>
  76. </Page>
  77. )
  78. }
  79. onPriceChange(values) {
  80. this.setState({
  81. priceMin: values[0],
  82. priceMax: values[1],
  83. });
  84. }
  85. }