@mshafiqyajid/react-select

Headless select hook and styled dropdown for React. Single and multi-select, searchable, clearable, chips for multi-value, portal positioning, full keyboard navigation.

Playground #

Props
TSX
import { SelectStyled } from "@mshafiqyajid/react-select/styled";
import "@mshafiqyajid/react-select/styles.css";

<SelectStyled
  items={items}
  value={value}
  onChange={setValue}
/>

Install #

npm install @mshafiqyajid/react-select

Quick start #

import { SelectStyled } from "@mshafiqyajid/react-select/styled";
import "@mshafiqyajid/react-select/styles.css";

const items = [
  { value: "react",  label: "React" },
  { value: "vue",    label: "Vue" },
  { value: "svelte", label: "Svelte" },
];

const [value, setValue] = useState("");

<SelectStyled
  items={items}
  value={value}
  onChange={setValue}
  placeholder="Pick a framework"
/>

Multi-select #

const [values, setValues] = useState<string[]>([]);

<SelectStyled
  items={items}
  value={values}
  onChange={setValues}
  multiple
  clearable
/>

Searchable #

<SelectStyled items={items} value={value} onChange={setValue} searchable />

API #

PropTypeDefaultDescription
itemsSelectItem[]β€”Array of { value, label, disabled? }
valuestring | string[]β€”Selected value(s)
onChange(v: string | string[]) => voidβ€”Called on selection change
placeholderstring"Select…"Placeholder text
multiplebooleanfalseAllow multiple selections
searchablebooleanfalseShow search input in dropdown
clearablebooleanfalseShow clear button
size"sm" | "md" | "lg""md"Size variant
tone"neutral" | "primary" | "success" | "danger""neutral"Color tone
disabledbooleanfalseDisable the select
Edit this page on GitHub