stitch-ui
Version:
29 lines (25 loc) • 579 B
JavaScript
import React from "react";
import PropTypes from "prop-types";
export default function Switch({ checked, name, onChange }) {
return (
<div className="switch">
<input
id={`enable-${name}`}
type="checkbox"
checked={checked}
onChange={onChange}
className="slide-toggle-round"
/>
<label htmlFor={`enable-${name}`} />
</div>
);
}
Switch.propTypes = {
checked: PropTypes.bool,
name: PropTypes.string.isRequired,
onChange: PropTypes.func
};
Switch.defaultProps = {
checked: false,
onChange: () => {}
};