Serafim

Listbox [react-aria]

Component 1

About

Listbox with react-aria

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Listbox [react-aria] to your project and fits it to your theme.

Code

How Listbox [react-aria] is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

import { Label } from "@/components/ui/label";
import { 
  ListBox, 
  ListBoxItem, 
  ListBoxSection, 
  ListBoxHeader, 
  ListBoxSeparator 
} from "@/components/ui/listbox";

function Example() {
  return (
    <div className="space-y-2 min-w-[300px]">
      <Label>Listbox with option groups</Label>
      <div className="overflow-hidden rounded-lg border border-input">
        <ListBox
          aria-label="Select some foods"
          selectionMode="multiple"
          defaultSelectedKeys={["lettuce", "tuna"]}
        >
          <ListBoxSection>
            <ListBoxHeader>Veggies</ListBoxHeader>
            <ListBoxItem id="lettuce">Lettuce</ListBoxItem>
            <ListBoxItem id="tomato">Tomato</ListBoxItem>
            <ListBoxItem id="onion">Onion</ListBoxItem>
          </ListBoxSection>
          <ListBoxSeparator />
          <ListBoxSection>
            <ListBoxHeader>Protein</ListBoxHeader>
            <ListBoxItem id="ham">Ham</ListBoxItem>
            <ListBoxItem id="tuna">Tuna</ListBoxItem>
            <ListBoxItem id="tofu">Tofu</ListBoxItem>
          </ListBoxSection>
          <ListBoxSeparator />
          <ListBoxSection>
            <ListBoxHeader>Condiments</ListBoxHeader>
            <ListBoxItem id="mayo">Mayonnaise</ListBoxItem>
            <ListBoxItem id="mustard">Mustard</ListBoxItem>
            <ListBoxItem id="ranch">Ranch</ListBoxItem>
          </ListBoxSection>
        </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 { Example }

Dependencies

More by Serafim

View all
  • Spline Scene

    Spline Scene

    9.7K
  • Testimonials with Marquee

    Testimonials with Marquee

    2.4K
  • Gradient Button

    Gradient Button

    2K
  • Pixel Canvas

    Pixel Canvas

    923
  • Animated Blur Number

    Animated Blur Number

    834
  • Empty State

    Empty State

    797
  • Balloons

    Balloons

    788
  • Status Badge

    Status Badge

    692