1.0.9 • Published 4 years ago

@feizheng/react-radio-group v1.0.9

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

react-radio-group

Abstract radio component for react.

version license size download

installation

npm install -S @feizheng/react-radio-group

update

npm update @feizheng/react-radio-group

properties

NameTypeRequiredDefaultDescription
classNamestringfalse-The extended className for component.
disabledboolfalse-The input is disabled.
readOnlyboolfalse-The input is readOnly.
namestringtrue-The input name.
defaultValuestringfalse-Default value.
valuestringfalse-Runtime chnaged value.
itemsarrayfalse[]The radio group options.
templatefuncfalse-The radio option template.
onChangefuncfalsenoopThe handler when value changed.

usage

  1. import css

    @import "~@feizheng/react-radio-group/dist/style.scss";
    
    // customize your styles:
    $react-radio-group-options: ()
  2. import js

    import React from 'react';
    import ReactDOM from 'react-dom';
    import ReactRadioGroup from '@feizheng/react-radio-group';
    import './assets/style.scss';
    
    class App extends React.Component {
      state = {
        items: [
          {
            label: 'optino1',
            value: 'v1'
          },
          {
            label: 'optino2',
            value: 'v2'
          },
          {
            label: 'optino3',
            value: 'v3'
          }
        ]
      };
      render() {
        const { items } = this.state;
        return (
          <div className="app-container">
            <h3>normal</h3>
            <ReactRadioGroup
              name="abc"
              items={items}
              onChange={(e) => {
                console.log('events:', e.target.value);
              }}
            />
    
            <hr />
            <h3>disabled</h3>
    
            <ReactRadioGroup
              name="abcd"
              disabled
              items={items}
              onChange={(e) => {
                console.log('events:', e.target.value);
              }}
            />
            <hr />
            <h3>readonly</h3>
    
            <ReactRadioGroup
              name="abcde"
              readOnly
              value={'v1'}
              items={items}
              onChange={(e) => {
                console.log('events:', e.target.value);
              }}
            />
          </div>
        );
      }
    }
    
    ReactDOM.render(<App />, document.getElementById('app'));

documentation

license

Code released under the MIT license.

1.0.9

4 years ago

1.0.8

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago