A fully accessible, customizable dropdown select component built with Next.js, TypeScript, and Tailwind CSS.
https://dropdown-facundo.vercel.app
git clone https://github.com/facuperezm/take-home-challenge.git
cd take-home-challenge
pnpm i
pnpm test
pnpm dev
import { DropdownSelect } from "@your-package/dropdown-select";
const options = [
{ value: "red", label: "Red" },
{ value: "blue", label: "Blue" },
{ value: "green", label: "Green" },
];
function App() {
return (
<DropdownSelect
label="Select a color"
options={options}
onChange={(value) => console.log(value)}
isSearchable
/>
);
}
function App() {
const [value, setValue] = useState("red");
const [isOpen, setIsOpen] = useState(false);
return (
<DropdownSelect
label="Select a color"
options={options}
value={value}
open={isOpen}
onChange={setValue}
onOpenChange={setIsOpen}
isSearchable
/>
);
}
Prop | Type | Default | Description |
---|---|---|---|
label |
string |
Required | Placeholder text when no option is selected |
options |
Array<{ value: string, label: string }> |
Required | Array of options to display |
onChange |
(value: string) => void |
Required | Callback when selection changes |
isSearchable |
boolean |
false |
Enable search functionality |
value |
string |
- | Controlled mode: selected value |
open |
boolean |
- | Controlled mode: dropdown open state |
onOpenChange |
(isOpen: boolean) => void |
- | Controlled mode: open state callback |