Docs
Select
Select
Displays a list of options for the user to pick from—triggered by a button.
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@repo/tailwindcss/default/select";
const SelectDemo = () => {
return (
<Select
options={["Apple", "Banana", "Blueberry", "Grapes", "Pineapple"]}
placeholder="Select a fruit…"
itemComponent={(props) => (
<SelectItem item={props.item}>{props.item.rawValue}</SelectItem>
)}
>
<SelectTrigger class="w-[180px]">
<SelectValue<string>>{(state) => state.selectedOption()}</SelectValue>
</SelectTrigger>
<SelectContent />
</Select>
);
};
export default SelectDemo;
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@repo/tailwindcss/solid/select";
const SelectDemo = () => {
return (
<Select
options={["Apple", "Banana", "Blueberry", "Grapes", "Pineapple"]}
placeholder="Select a fruit…"
itemComponent={(props) => (
<SelectItem item={props.item}>{props.item.rawValue}</SelectItem>
)}
>
<SelectTrigger class="w-[180px]">
<SelectValue<string>>{(state) => state.selectedOption()}</SelectValue>
</SelectTrigger>
<SelectContent />
</Select>
);
};
export default SelectDemo;
Installation
npx shadcn-solid@latest add select
Install the following dependencies:
npm install @kobalte/core
Copy and paste the following code into your project:
Install the following dependencies:
npm install @kobalte/core
Copy and paste the following code into your project:
Usage
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue
} from "@/components/ui/select";
<Select
options={["Apple", "Banana", "Blueberry", "Grapes", "Pineapple"]}
itemComponent={props => <SelectItem item={props.item}>{props.item.rawValue}</SelectItem>}
>
<SelectTrigger>
<SelectValue<string>>{state => state.selectedOption()}</SelectValue>
</SelectTrigger>
<SelectContent />
</Select>