Dropdown UI
Dropdown UI is a simple React component library that implements one component - Dropdown.
Installation
Add the library to your project by running one of the following commands:
npm install @marjak93/dropdown-ui
or
yarn add @marjak93/dropdown-ui
Usage
Dropdown has two parts - Select
and Option
. The syntax is inspired by the classic <select>
and <option>
tags in HTML.
import { Dropdown } from "@marjak93/dropdown-ui";
const MyDropdown = () => {
const [myValue, setMyValue] = React.useState(null);
const handleChange = (value) => {
setMyValue(value);
};
return (
<Dropdown.Select label="Age" value={myValue} onChange={handleChange}>
<Dropdown.Option value="10">10</Dropdown.Option>
<Dropdown.Option value="20">20</Dropdown.Option>
<Dropdown.Option value="30">30</Dropdown.Option>
</Dropdown.Select>
);
};