@jswork/react-ant-checkbox-group
v1.0.5
Published
React ant checkbox group.
Downloads
31
Readme
react-ant-checkbox-group
React ant checkbox group.
installation
npm install -S @jswork/react-ant-checkbox-group
properties
| Name | Type | Required | Default | Description | | --------- | ------ | -------- | ---------------- | ------------------------------------- | | className | string | false | - | The extended className for component. | | value | array | false | - | Default value. | | onChange | func | false | noop | The change handler. | | onSearch | func | false | noop | The handler when search. | | items | array | false | [] | The checkbox data source. | | template | func | false | RctplAntCheckbox | The item template. | | styleless | bool | false | false | If no checkbox ui. |
usage
- import css
@import "~@jswork/react-ant-checkbox-group/dist/style.css";
// or use sass
@import "~@jswork/react-ant-checkbox-group/dist/style.scss";
// customize your styles:
$react-ant-checkbox-group-options: ()
- import js
import ReactDemokit from '@jswork/react-demokit';
import React from 'react';
import ReactDOM from 'react-dom';
import ReactAntCheckboxGroup from '@jswork/react-ant-checkbox-group';
import './assets/style.scss';
class App extends React.Component {
state = {
value: ['k1', 'k3'],
items: [
{ value: 'k1', label: 'label1' },
{ value: 'k2', label: 'label2' },
{ value: 'k3', label: 'label3' }
]
};
onChange = (inEvent) => {
// console.log('chk change:', inEvent.target.value);
this.setState({ value: inEvent.target.value });
};
render() {
return (
<ReactDemokit
className="p-3 app-container"
url="https://github.com/afeiship/react-ant-checkbox-group">
<article className="message is-info mb-3">
<div className="message-header">Demo</div>
<div className="message-body">
<div className="p-2">
<ReactAntCheckboxGroup
name="abc"
value={this.state.value}
onChange={this.onChange}
onSearch={(e) => {
console.log('event:', e.target.value);
}}
items={this.state.items}
/>
</div>
<ReactAntCheckboxGroup
name="abcd"
styleless
value={this.state.value}
onChange={this.onChange}
items={this.state.items}
/>
</div>
</article>
<article className="message">
<div className="message-header">Output</div>
<div className="message-body">{JSON.stringify(this.state.value)}</div>
</article>
</ReactDemokit>
);
}
}
ReactDOM.render(<App />, document.getElementById('app'));
documentation
- https://afeiship.github.io/react-ant-checkbox-group/
license
Code released under the MIT license.