1.0.0 • Published 4 years ago

@jswork/react-range v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

react-range

Pure range form element for react.

version license size download

installation

npm install -S @jswork/react-range

properties

NameTypeRequiredDefaultDescription
classNamestringfalse-The extended className for component.
valuestringfalse-The runtime value.
defaultValuestringfalse-The default value.
namestringfalse-The form control name.
onChangefuncfalsenoopThe handler when data change.

usage

  1. import css

    @import "~@jswork/react-range/dist/style.css";
    
    // or use sass
    @import "~@jswork/react-range/dist/style.scss";
    
    // customize your styles:
    $react-range-options: ()
  2. import js

    import ReactDemokit from '@jswork/react-demokit';
    import React from 'react';
    import ReactDOM from 'react-dom';
    import ReactRange from '@jswork/react-range';
    import './assets/style.scss';
    
    class App extends React.Component {
      state = { value: 2 };
      render() {
        return (
          <ReactDemokit
            className="p-3 app-container"
            url="https://github.com/afeiship/react-range">
            <article class="message is-info">
              <div class="message-header">Preview:</div>
              <div class="message-body">
                <ReactRange
                  min="2"
                  max="10"
                  step="2"
                  value={this.state.value}
                  onChange={(e) => {
                    this.setState({ value: e.target.value });
                  }}
                />
              </div>
            </article>
    
            <article class="message">
              <div class="message-header">Value changed:</div>
              <div class="message-body">{JSON.stringify(this.state.value)}</div>
            </article>
          </ReactDemokit>
        );
      }
    }
    
    ReactDOM.render(<App />, document.getElementById('app'));

documentation

license

Code released under the MIT license.

1.0.0

4 years ago