componentsSelect with Search

Preview

Responsive Select with Search

Selected value:

Usage

import React from "react";
import { SelectWithSearch } from "@/components/ui/select-with-search";
 
export default function App() {
  const [value, setValue] = React.useState("");
  const options = [
    { label: "Option 1", value: "1" },
    { label: "Option 2", value: "2" },
    {
      label: "Group 3",
      options: [
        { label: "Option 3.1", value: "3.1" },
        { label: "Option 3.2", value: "3.2" },
        ,
      ],
    },
  ];
 
  return (
    <SelectWithSearch
      options={options}
      value={value}
      onValueChange={(value) => setValue(value)}
      disabled={false}
      placeholder="Select an option"
    />
  );
}

Installation

Add the required hooks:

npx shadcn@latest add http://127.0.0.1:8080/r/styles/default/use-media-query.json

Add the component:

npx shadcn@latest add https://components.celeroncoder.com/r/styles/default/select-with-search.json