oc-js-react-p14-dropdown
v1.0.5
Published
React dropdown component to replace jQuery plugin for HRnet project
Downloads
15
Readme
oc-js-react-p14-dropdown
React dropdown component to replace jQuery plugin for the HRnet project.
Installation
npm install oc-js-react-p14-dropdownor with Yarn:
yarn add oc-js-react-p14-dropdownUsage
import React, { useState } from "react";
import Dropdown from "oc-js-react-p14-dropdown/dist/dropdown.es.js";
import "oc-js-react-p14-dropdown/dist/oc-js-react-p14-dropdown.css";
function Example() {
const [value, setValue] = useState("");
function handleChange(event) {
setValue(event.target.value);
}
return (
<Dropdown
label="Select an option"
name="example"
value={value}
onChange={handleChange}
options={["Option 1", "Option 2", "Option 3"]}
error={value ? "" : "This field is required."}
/>
);
}
export default Example;Props
| Prop | Type | Required | Description | | -------- | ---------------- | -------- | ------------------------------------------- | | label | string | yes | Label displayed above the dropdown | | name | string | yes | HTML name attribute | | value | string | no | Selected value | | onChange | function | yes | Change handler function | | options | array of strings | yes | List of selectable options | | error | string | no | Error message displayed below the dropdown |
Development
Clone the repo and install dependencies:
git clone https://github.com/manuo1/oc-js-react-p14-dropdown.git
cd oc-js-react-p14-dropdown
npm installStart dev server:
npm run devBuild the package:
npm run buildLicense
MIT © Ton Nom
