Components
Loading preview...
Listbox with react-aria
npx shadcn@latest add https://21st.dev/r/serafimcloud/listbox"use client";
import { Label } from "@/components/ui/label";
import { ListBox, ListBoxItem } from "@/components/ui/listbox";
function ListBoxSingle() {
return (
<div className="space-y-2">
<Label>Listbox with single option</Label>
<div className="overflow-hidden rounded-lg border border-input">
<ListBox
className="space-y-1 bg-background p-1 text-sm shadow-sm shadow-black/5 transition-shadow"
aria-label="Select framework"
selectionMode="single"
defaultSelectedKeys={["svelte"]}
>
<ListBoxItem id="react">React</ListBoxItem>
<ListBoxItem id="vue">Vue</ListBoxItem>
<ListBoxItem id="angular" isDisabled>Angular</ListBoxItem>
<ListBoxItem id="svelte">Svelte</ListBoxItem>
</ListBox>
</div>
<p className="mt-2 text-xs text-muted-foreground">
Built with{" "}
<a
className="underline hover:text-foreground"
href="https://react-spectrum.adobe.com/react-aria/ListBox.html"
target="_blank"
rel="noopener nofollow"
>
React Aria
</a>
</p>
</div>
);
}
export { ListBoxSingle }