Range Slider React Component
Range Slider React component represents Range Slider component.
Range Slider Components
There are following components included:
Range
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 | Minimal step between values |
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 |
Examples
range.jsx
import React, { useState } from 'react';
import { Navbar, Page, BlockTitle, Range, List, ListItem, Icon, Block } from 'framework7-react';
export default () => {
const [priceMin, setPriceMin] = useState(200);
const [priceMax, setPriceMax] = useState(400);
const onPriceChange = (values) => {
setPriceMin(values[0]);
setPriceMax(values[1]);
};
return (
<Page>
<Navbar title="Range Slider"></Navbar>
<BlockTitle>Volume</BlockTitle>
<List simpleList outlineIos strongIos>
<ListItem>
<div>
<Icon ios="f7:speaker_fill" md="material:volume_mute" />
</div>
<div style={{ width: '100%', margin: '0 16px' }}>
<Range min={0} max={100} step={1} value={10} />
</div>
<div>
<Icon ios="f7:speaker_3_fill" md="material:volume_up" />
</div>
</ListItem>
</List>
<BlockTitle>Brightness</BlockTitle>
<List simpleList outlineIos strongIos>
<ListItem>
<div>
<Icon ios="f7:sun_min" md="material:brightness_low" />
</div>
<div style={{ width: '100%', margin: '0 16px' }}>
<Range min={0} max={100} step={1} value={50} label={true} color="orange" />
</div>
<div>
<Icon ios="f7:sun_max_fill" md="material:brightness_high" />
</div>
</ListItem>
</List>
<BlockTitle className="display-flex justify-content-space-between">
Price Filter{' '}
<span>
${priceMin} - ${priceMax}
</span>
</BlockTitle>
<List simpleList outlineIos strongIos>
<ListItem>
<div>
<Icon ios="f7:money_dollar_circle" md="material:attach_money" />
</div>
<div style={{ width: '100%', margin: '0 16px' }}>
<Range
min={0}
max={500}
step={1}
value={[priceMin, priceMax]}
label={true}
dual={true}
color="green"
onRangeChange={onPriceChange}
/>
</div>
<div>
<Icon ios="f7:money_dollar_circle_fill" md="material:monetization_on" />
</div>
</ListItem>
</List>
<BlockTitle>With Scale</BlockTitle>
<Block strongIos outlineIos>
<Range
min={0}
max={100}
label={true}
step={5}
value={25}
scale={true}
scaleSteps={5}
scaleSubSteps={4}
/>
</Block>
<BlockTitle>Vertical</BlockTitle>
<Block strongIos outlineIos className="display-flex justify-content-center">
<Range
className="margin-right"
style={{ height: '160px' }}
vertical={true}
min={0}
max={100}
label={true}
step={1}
value={25}
/>
<Range
className="margin-horizontal"
style={{ height: '160px' }}
vertical={true}
min={0}
max={100}
label={true}
step={1}
value={50}
/>
<Range
className="margin-horizontal"
style={{ height: '160px' }}
vertical={true}
min={0}
max={100}
label={true}
step={1}
value={75}
/>
<Range
className="margin-left"
style={{ height: '160px' }}
dual={true}
vertical={true}
min={0}
max={100}
label={true}
step={1}
value={[25, 75]}
/>
</Block>
<BlockTitle>Vertical Reversed</BlockTitle>
<Block strongIos outlineIos className="display-flex justify-content-center">
<Range
className="margin-right"
color="red"
style={{ height: '160px' }}
vertical={true}
verticalReversed={true}
min={0}
max={100}
label={true}
step={1}
value={25}
/>
<Range
className="margin-horizontal"
color="red"
style={{ height: '160px' }}
vertical={true}
verticalReversed={true}
min={0}
max={100}
label={true}
step={1}
value={50}
/>
<Range
className="margin-horizontal"
color="red"
style={{ height: '160px' }}
vertical={true}
verticalReversed={true}
min={0}
max={100}
label={true}
step={1}
value={75}
/>
<Range
className="margin-left"
color="red"
style={{ height: '160px' }}
dual={true}
vertical={true}
verticalReversed={true}
min={0}
max={100}
label={true}
step={1}
value={[25, 75]}
/>
</Block>
</Page>
);
};