react-option-picker v0.1.0
react-option-picker
A react select element that provides the elements and logic only - no built-in styling.
Installation
With npm:
npm install react-option-pickerUse
To use:
import { useState } from "react";
import Select from "react-option-picker";
export const App = () => {
const [number, setNumber] = useState(null);
const options = [
{id: 1, label: "one"},
{id: 2, label: "two"},
{id: 3, label: "three"},
{id: 4, label: "four"},
]
return (
<div>
<Select
options={options}
value={number}
setValue={setNumber}
className="big-text"
inputClassName="small-text"
/>
</div>
)
}Styling
The Select is made of various sub-components, each of which can have style applied directly - either by using its built-in class name or by applying your own class name.
The parent component
- has
option-pickerclass. - also has
option-picker-openclass when theSelectis showing options. classNameprop to apply your own class name.openClassNameprop to apply classes whenSelectis showing options.
The input component
This displays whatever the currently selected value is.
- has
option-picker-inputclass. - also has
option-picker-input-openclass when theSelectis showing options. inputClassNameprop to apply your own class name.openInputClassNameprop to apply classes whenSelectis showing options.
The options component
This contains the list of selectable options.
- has
option-picker-optionsclass. optionsClassNameprop to apply your own class name.
The option components
This shows a single selectable option
- has
option-picker-optionclass. - has
option-picker-option-selectedclass when it is the current selected item. optionClassNameprop to apply your own class name.selectedPptionClassNameprop to apply your own class name when it is the current selected item.
Development
Rollup is used to build the package to dist/index.js. To install the tools needed for this:
npm install --legacy-peer-depsThis option is used because some of the dev dependencies have react as a peer dependency, and it is important that this does not get installed as it prevents the library from being installed locally.
To continuously build while developing:
npm run devTo make a final, publishable build:
npm run buildChangelog
Release 0.1.0
3 June 2023
- Initial Select component with static options.
- Initial styling system.
2 years ago