ComponentsSelection & pickers
Select
A field that opens a list of options and keeps one, with icons, avatars, sections and an optional search.
Default
"use client";
import { Select, SelectItem } from "@/components/miyuki-ui/select";
const resorts = ["Niseko", "Hakuba", "Nozawa", "Lake Tōya", "Kiso", "Matsumoto"];
export default function SelectDemo() {
return (
<Select
className="w-full max-w-xs"
label="Resort"
placeholder="Choose a resort"
defaultValue="hakuba"
description="Lift prices update for the resort you choose."
>
{resorts.map((name) => (
<SelectItem key={name} id={name.toLowerCase()}>
{name}
</SelectItem>
))}
</Select>
);
}Avatars and descriptions
This example uses sample data from this site: data.ts, which also needs art.ts. Copy those files from the repository, or use your own data in their place.
"use client";
import { Select, SelectItem } from "@/components/miyuki-ui/select";
import { people } from "@/registry/lib/data";
const guides = [people[0], people[5], people[6], people[2], people[8], people[7]];
export default function SelectAvatarsDemo() {
return (
<Select
className="w-full max-w-xs"
label="Assign a guide"
placeholder="Choose a guide"
items={guides}
defaultValue="aiko.tanaka"
>
{(person) => (
<SelectItem id={person.handle} avatar={person.avatar} description={person.role}>
{person.name}
</SelectItem>
)}
</Select>
);
}Searchable, with sections
"use client";
import { Select, SelectItem, SelectSection } from "@/components/miyuki-ui/select";
const regions = [
{ name: "Hokkaido", prefectures: ["Hokkaido"] },
{ name: "Tōhoku", prefectures: ["Aomori", "Iwate", "Akita", "Miyagi", "Yamagata", "Fukushima"] },
{ name: "Chūbu", prefectures: ["Niigata", "Toyama", "Ishikawa", "Fukui", "Nagano", "Gifu", "Yamanashi"] },
{ name: "Kantō", prefectures: ["Gunma", "Tochigi"] },
];
export default function SelectSearchableDemo() {
return (
<Select
className="w-full max-w-xs"
label="Prefecture"
placeholder="Choose a prefecture"
searchable
searchPlaceholder="Search prefectures"
>
{regions.map((region) => (
<SelectSection key={region.name} title={region.name}>
{region.prefectures.map((name) => (
<SelectItem key={name} id={name.toLowerCase()}>
{name}
</SelectItem>
))}
</SelectSection>
))}
</Select>
);
}Install
npx shadcn@latest add @miyuki-ui/selectThis needs the @miyuki-ui registry in your components.json. See Using the shadcn CLI.
Props
Select
Prop
Type
SelectItem
Prop
Type
SelectSection
Prop
Type