0.0.8 ā€¢ Published 2 years ago

@robertz65/lyte v0.0.8

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Lyte

A collection of highly extensible React components, including Selectable, a beautiful (multi)select dropdown you've been looking for.

showcase

Installation

npm install @robertz65/lyte

Selectable

šŸ”˜ Multiselect šŸ”­ Full TypeScript support šŸŒ“ Dark mode (Tailwind CSS)

Import

import { Selectable } from "@robertz65/lyte";

Documentation

PropTypeRequirementDescription
widthnumber | stringrequiredThe width of the Selectable component. Either a number corresponding to a number of pixels or "100%" to match the width of its parent.
options{label: string | number; content?: ReactNode | string}[]requiredThe collection of options to select from.
defaultValuestring | number | string[] | number[]requiredThe label of the value(s) that are selected by default. When multi is not specified or set to false, _default is a single string or number. Otherwise, it is an array.
multibooleanoptionalWhether Selectable can select multiple options. Defaults to false.
onChange(values: {label: string | number; content?: ReactNode | string}[]) => voidoptionalTracks changes to the selected options. When multi is not specified or set to false, values is a one-item array with the single selected option.
allowClearbooleanoptionalWhether to show clear button to unselect all options. Defaults to false. Only works under multi mode.
allowRefillbooleanoptionalWhether to show refill button to select all options. Defaults to false. Only works under multi mode.
classNamestringoptionalA list of classes applied to Selectable.
menuPlacement"top" | "bottom"optionalWhether the options menu appears above or below Selectable. Defaults to "bottom". Only works under single selection mode.

Example Usage

import { Selectable } from "@robertz65/lyte";

const SelectableOptions = [
  { label: 1, content: "Option 1" },
  { label: 2, content: "Option 2" },
  { label: 3, content: "Option 3" },
];

const DemoComponent = () => {
  return (
    <Selectable
      width={260}
      multi
      allowClear
      allowRefill
      options={SelectableOptions}
      defaultValue={SelectableOptions.map(({ label }) => label)}
      onChange={(values) => console.log(values)}
    />
  );
};

export default DemoComponent;
0.0.9

1 year ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago