React Checkbox MultiSelect

Developer
Size
6,915 Kb
Views
123,464

How do I make an react checkbox multiselect?

What is a react checkbox multiselect? How do you make a react checkbox multiselect? This script and codes were developed by Travis Arnold on 12 September 2022, Monday.

React Checkbox MultiSelect Previews

React Checkbox MultiSelect - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>React Checkbox MultiSelect</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <style> /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */ .react-select { display: inline-block; width: 100%; height: auto; position: relative;
}
.react-select-trigger { box-sizing: border-box; display: flex; width: 100%; height: 31px; padding: 6px 27px 6px 6px; font-size: 14px; text-align: left; border-radius: 3px; border: 1px solid #d3d4d4; outline: 0; cursor: pointer; position: relative; background-color: #fff; background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="21px" height="21px" viewBox="0 0 21 21"><polygon points="10.5,12 7,8.5 14,8.5"/></svg>'); background-repeat: no-repeat; background-position: calc(100% - 5px) center;
}
.react-select-trigger, .react-select-trigger:active { color: black;
}
.react-select-trigger.react-select-target-attached-top { border-radius: 0 0 3px 3px;
}
.react-select-trigger.react-select-target-attached-bottom { border-radius: 3px 3px 0 0;
}
.react-select-trigger * { white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.react-select-trigger__option { user-select: none;
}
.react-select-trigger__option + .react-select-trigger__option { margin-left: 6px;
}
.react-select-trigger--multiple .react-select-trigger__option { padding: 0 3px; border-radius: 2px; background: #E6F9FF;
}
.react-select-trigger__arrow { position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
}
.react-select-menu { max-height: 180px; padding: 3px 0; border: 1px solid #e1e1e1; border-radius: 0 0 3px 3px; box-shadow: 0 2px 4px 0 rgba(218, 221, 222, 0.35); background-color: white; overflow-x: hidden; overflow-y: auto; pointer-events: none; -webkit-tap-highlight-color: transparent;
}
.react-select-enabled .react-select-menu { pointer-events: auto;
}
.react-select-element-attached-top .react-select-menu { margin-top: -1px; border-top: 0;
}
.react-select-element-attached-bottom .react-select-menu { margin-top: 1px; border-bottom: 0; border-radius: 3px 3px 0 0; box-shadow: 0 -2px 4px 0 rgba(218, 221, 222, 0.35);
}
.react-select-header { display: flex; padding: 8px; border-bottom: 1px solid #F1F3F5; border-top: 1px solid #F1F3F5;
}
.react-select-btn { flex: 1;
}
.react-select-options { padding: 0; margin: 0; list-style: none;
}
.react-select-option { display: flex; align-items: center; padding: 4px 8px; font-size: 14px; text-indent: 4px; border-radius: 2px; cursor: pointer; user-select: none;
}
.react-select-option:hover { background: #FBFBFB;
}
.react-select-option__label { width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.react-select-optgroup { display: block; padding: 3px 0; cursor: default; border-top: 1px solid #F1F3F5;
}
.react-select-optgroup:first-child { border: 0;
}
.react-select-optgroup__title { display: block; padding: 8px 12px 6px; font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: #909294; user-select: none;
}
* { box-sizing: border-box;
}
html,
body { width: 100%; height: 100%;
}
body { padding: 24px;
}
#app { width: 300px; margin: 0 auto;
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <div id="app"></div> <script src='https://fb.me/react-15.0.1.js'></script>
<script src='https://fb.me/react-dom-15.0.1.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/tether/1.2.0/js/tether.min.js'></script>
<script src='https://npmcdn.com/[email protected]/dist/react-tether.js'></script>
<script src='https://s3-us-west-2.amazonaws.com/s.cdpn.io/50370/selectly.js'></script> <script src="js/index.js"></script>
</body>
</html>

React Checkbox MultiSelect - Script Codes CSS Codes

.react-select { display: inline-block; width: 100%; height: auto; position: relative;
}
.react-select-trigger { box-sizing: border-box; display: flex; width: 100%; height: 31px; padding: 6px 27px 6px 6px; font-size: 14px; text-align: left; border-radius: 3px; border: 1px solid #d3d4d4; outline: 0; cursor: pointer; position: relative; background-color: #fff; background-image: url('data:image/svg+xml;utf8,'); background-repeat: no-repeat; background-position: calc(100% - 5px) center;
}
.react-select-trigger, .react-select-trigger:active { color: black;
}
.react-select-trigger.react-select-target-attached-top { border-radius: 0 0 3px 3px;
}
.react-select-trigger.react-select-target-attached-bottom { border-radius: 3px 3px 0 0;
}
.react-select-trigger * { white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.react-select-trigger__option { user-select: none;
}
.react-select-trigger__option + .react-select-trigger__option { margin-left: 6px;
}
.react-select-trigger--multiple .react-select-trigger__option { padding: 0 3px; border-radius: 2px; background: #E6F9FF;
}
.react-select-trigger__arrow { position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
}
.react-select-menu { max-height: 180px; padding: 3px 0; border: 1px solid #e1e1e1; border-radius: 0 0 3px 3px; box-shadow: 0 2px 4px 0 rgba(218, 221, 222, 0.35); background-color: white; overflow-x: hidden; overflow-y: auto; pointer-events: none; -webkit-tap-highlight-color: transparent;
}
.react-select-enabled .react-select-menu { pointer-events: auto;
}
.react-select-element-attached-top .react-select-menu { margin-top: -1px; border-top: 0;
}
.react-select-element-attached-bottom .react-select-menu { margin-top: 1px; border-bottom: 0; border-radius: 3px 3px 0 0; box-shadow: 0 -2px 4px 0 rgba(218, 221, 222, 0.35);
}
.react-select-header { display: flex; padding: 8px; border-bottom: 1px solid #F1F3F5; border-top: 1px solid #F1F3F5;
}
.react-select-btn { flex: 1;
}
.react-select-options { padding: 0; margin: 0; list-style: none;
}
.react-select-option { display: flex; align-items: center; padding: 4px 8px; font-size: 14px; text-indent: 4px; border-radius: 2px; cursor: pointer; user-select: none;
}
.react-select-option:hover { background: #FBFBFB;
}
.react-select-option__label { width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.react-select-optgroup { display: block; padding: 3px 0; cursor: default; border-top: 1px solid #F1F3F5;
}
.react-select-optgroup:first-child { border: 0;
}
.react-select-optgroup__title { display: block; padding: 8px 12px 6px; font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: #909294; user-select: none;
}
* { box-sizing: border-box;
}
html,
body { width: 100%; height: 100%;
}
body { padding: 24px;
}
#app { width: 300px; margin: 0 auto;
}

React Checkbox MultiSelect - Script Codes JS Codes

"use strict";
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var _React = React;
var Component = _React.Component;
var Children = _React.Children;
var PropTypes = _React.PropTypes;
var _Selectly = Selectly;
var Select = _Selectly.Select;
var Option = _Selectly.Option;
var utils = _Selectly.utils;
var getToggledOptions = utils.getToggledOptions;
var CheckboxOption = function (_Component) { _inherits(CheckboxOption, _Component); function CheckboxOption() { _classCallCheck(this, CheckboxOption); return _possibleConstructorReturn(this, _Component.apply(this, arguments)); } CheckboxOption.prototype.render = function render() { var _props = this.props; var value = _props.value; var isChecked = _props.isChecked; var children = _props.children; return React.createElement( Option, { className: "react-select-option", value: value }, React.createElement("input", { type: "checkbox", className: "react-select-option__checkbox", defaultValue: null, checked: isChecked }), React.createElement( "div", { className: "react-select-option__label" }, children ) ); }; return CheckboxOption;
}(Component);
var CheckboxMultiSelect = function (_Component2) { _inherits(CheckboxMultiSelect, _Component2); function CheckboxMultiSelect(props) { _classCallCheck(this, CheckboxMultiSelect); var _this2 = _possibleConstructorReturn(this, _Component2.call(this, props)); _this2.state = { defaultValue: 'Select a color', currentValues: [] }; _this2._handleChange = _this2._handleChange.bind(_this2); return _this2; } CheckboxMultiSelect.prototype._handleChange = function _handleChange(value) { this.setState({ currentValues: getToggledOptions(this.state.currentValues, value) }); }; CheckboxMultiSelect.prototype.render = function render() { var _state = this.state; var defaultValue = _state.defaultValue; var currentValues = _state.currentValues; return React.createElement( Select, { classPrefix: "react-select", multiple: true, onChange: this._handleChange }, React.createElement( "button", { className: "react-select-trigger" }, currentValues.length > 0 ? currentValues.join(', ') : defaultValue ), React.createElement( "div", { className: "react-select-menu" }, React.createElement( "ul", { className: "react-select-options" }, React.createElement( CheckboxOption, { value: "red", isChecked: currentValues.indexOf('red') > -1 }, "Red" ), React.createElement( CheckboxOption, { value: "green", isChecked: currentValues.indexOf('green') > -1 }, "Green" ), React.createElement( CheckboxOption, { value: "blue", isChecked: currentValues.indexOf('blue') > -1 }, "Blue" ) ) ) ); }; return CheckboxMultiSelect;
}(Component);
ReactDOM.render(React.createElement(CheckboxMultiSelect, null), document.getElementById('app'));
React Checkbox MultiSelect - Script Codes
React Checkbox MultiSelect - Script Codes
Home Page Home
Developer Travis Arnold
Username souporserious
Uploaded September 12, 2022
Rating 3
Size 6,915 Kb
Views 123,464
Do you need developer help for React Checkbox MultiSelect?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Travis Arnold (souporserious) Script Codes
Create amazing love letters with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!