GitHub

Select

Displays a list of options for the user to pick from—triggered by a button.

Docs

Your favorite fruit is:

Installation

npx solidui-cli@latest add select

Usage

import {
  Select,
  SelectContent,
  SelectItem,
  SelectTrigger,
  SelectValue
} from "~/components/ui/select"
const [value, setValue] = createSignal("")
<Select
    value={value()}
    onChange={setValue}
    options={["Apple", "Banana", "Blueberry", "Grapes", "Pineapple"]}
    placeholder="Select a fruit…"
    itemComponent={(props) => <SelectItem item={props.item}>{props.item.rawValue}</SelectItem>}
>
    <SelectTrigger aria-label="Fruit" class="w-[180px]">
        <SelectValue<string>>{(state) => state.selectedOption()}</SelectValue>
    </SelectTrigger>
    <SelectContent />
</Select>