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
1Minimal step between values
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

<Range> methods
.setValue(newValue)Set new range slider value
.getValue()Returns range slider value

Examples

export default class extends React.Component {
  constructor(props) {
    super(props);

    this.state = {
      priceMin: 200,
      priceMax: 400,
    }
  }
  render() {
    return (
      <Page>
        <Navbar title="Range Slider"></Navbar>

        <BlockTitle>Volume</BlockTitle>
        <List simpleList>
          <ListItem>
            <ListItemCell className="width-auto flex-shrink-0">
              <Icon ios="f7:speaker_fill" aurora="f7:speaker_fill" md="material:volume_mute"></Icon>
            </ListItemCell>
            <ListItemCell className="flex-shrink-3">
              <Range
                min={0}
                max={100}
                step={1}
                value={10}
              ></Range>
            </ListItemCell>
            <ListItemCell className="width-auto flex-shrink-0">
              <Icon ios="f7:speaker_3_fill" aurora="f7:speaker_3_fill" md="material:volume_up"></Icon>
            </ListItemCell>
          </ListItem>
        </List>

        <BlockTitle>Brightness</BlockTitle>
        <List simpleList>
          <ListItem>
            <ListItemCell className="width-auto flex-shrink-0">
              <Icon ios="f7:sun_min" aurora="f7:sun_min" md="material:brightness_low"></Icon>
            </ListItemCell>
            <ListItemCell className="flex-shrink-3">
              <Range
                min={0}
                max={100}
                step={1}
                value={50}
                label={true}
                color="orange"
              ></Range>
            </ListItemCell>
            <ListItemCell className="width-auto flex-shrink-0">
              <Icon ios="f7:sun_max_fill" aurora="f7:sun_max_fill" md="material:brightness_high"></Icon>
            </ListItemCell>
          </ListItem>
        </List>

        <BlockTitle className="display-flex justify-content-space-between">Price Filter <span>${this.state.priceMin} - ${this.state.priceMax}</span></BlockTitle>
        <List simpleList>
          <ListItem>
            <ListItemCell className="width-auto flex-shrink-0">
              <Icon ios="f7:money_dollar_circle" aurora="f7:money_dollar_circle" md="material:attach_money"></Icon>
            </ListItemCell>
            <ListItemCell className="flex-shrink-3">
              <Range
                min={0}
                max={500}
                step={1}
                value={[this.state.priceMin, this.state.priceMax]}
                label={true}
                dual={true}
                color="green"
                onRangeChange={this.onPriceChange.bind(this)}
              ></Range>
            </ListItemCell>
            <ListItemCell className="width-auto flex-shrink-0">
              <Icon ios="f7:money_dollar_circle_fill" aurora="f7:money_dollar_circle_fill" md="material:monetization_on"></Icon>
            </ListItemCell>
          </ListItem>
        </List>

        <BlockTitle>With Scale</BlockTitle>
        <Block strong>
          <Range
            min={0}
            max={100}
            label={true}
            step={5}
            value={25}
            scale={true}
            scaleSteps={5}
            scaleSubSteps={4}
          />
        </Block>

        <BlockTitle>Vertical</BlockTitle>
        <Block strong 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 strong 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>
    )
  }
  onPriceChange(values) {
    this.setState({
      priceMin: values[0],
      priceMax: values[1],
    });
  }
}