Skip to content
Molecules

Select

A listbox with type-ahead and keys.

Primitive

Variants

3 more takes on the select, each a single file you install on its own by its id.

aui-043Rich options

Options with icons and descriptions.

$ pnpm dlx asta-ui@latest add select-aui-043

Or with the shadcn CLI: pnpm dlx shadcn@latest add https://ui.astabyte.com/r/select-aui-043.json

aui-044Inline pill

A select inside a sentence.

$ pnpm dlx asta-ui@latest add select-aui-044

Or with the shadcn CLI: pnpm dlx shadcn@latest add https://ui.astabyte.com/r/select-aui-044.json

aui-045Grouped

Time zones by region, with search.

$ pnpm dlx asta-ui@latest add select-aui-045

Or with the shadcn CLI: pnpm dlx shadcn@latest add https://ui.astabyte.com/r/select-aui-045.json

Installation

Primitive
  1. Run the CLI

    Run pnpm dlx asta-ui@latest init once, then this. The file lands in components/astabyte/, installs radix-ui@base-ui/react and the colour tokens go into your CSS. This is the Radix build. Drop --radix for Base UI.This is the Base UI build, the default. Want Radix? Add --radix.

    $ pnpm dlx asta-ui@latest add select --radix

    Or with the shadcn CLI: pnpm dlx shadcn@latest add https://ui.astabyte.com/r/base/select.json

  2. Or install the package

    Don’t want the file? Import from asta-uiasta-ui/base and update with pnpm update asta-ui. Add the stylesheet once. More.

    $ pnpm add asta-ui radix-ui @base-ui/react
    import { Select } from "asta-ui";
    import { Select } from "asta-ui/base";
  3. Or copy it by hand

    Install radix-ui@base-ui/react, then copy this file. Keep the paths, or fix the @/ imports. Then add the tokens from globals.css.

    "use client";
    
    import { Popover, Select as S } from "radix-ui";
    import { useEffect, useId, useMemo, useRef, useState, type KeyboardEvent, type ReactNode } from "react";
    
    const cx = (...c: (string | false | null | undefined)[]) => c.filter(Boolean).join(" ");
    
    export interface SelectOption {
      value: string;
      label: string;
      icon?: ReactNode;
      hint?: string;
      disabled?: boolean;
    }
    
    export interface SelectProps {
      options: SelectOption[];
      value?: string;
      defaultValue?: string;
      onChange?: (value: string) => void;
      placeholder?: string;
      /** Adds a filter box at the top of the list. */
      searchable?: boolean;
      label?: string;
      size?: "sm" | "md";
      /** Form field name (submits the value with a form). */
      name?: string;
      disabled?: boolean;
      className?: string;
    }
    
    const KEYFRAMES = `@keyframes kit-select-in { from { opacity: 0; transform: translateY(-4px) scale(.97) } }
    @keyframes kit-select-out { to { opacity: 0; transform: scale(.98) } }`;
    
    const trigger = (size: "sm" | "md") =>
      cx(
        "group/sel flex w-full items-center gap-2 bg-paper text-left outline-none transition-shadow duration-200 focus-visible:ring-2 focus-visible:ring-brand/50 disabled:cursor-not-allowed disabled:opacity-45",
        "shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--color-ink)_14%,transparent)] hover:shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--color-ink)_24%,transparent)]",
        "data-[state=open]:!shadow-[inset_0_0_0_1px_var(--color-brand),0_0_0_3px_color-mix(in_srgb,var(--color-brand)_18%,transparent)]",
        size === "sm" ? "h-8 rounded-md px-2.5 text-[13px]" : "h-10 rounded-lg px-3 text-[14px]",
      );
    
    const panel = (origin: string) =>
      cx(
        "z-50 overflow-hidden rounded-xl bg-paper p-1 outline-none",
        "shadow-[0_0_0_1px_color-mix(in_srgb,var(--color-ink)_10%,transparent),0_12px_32px_-8px_rgb(0_0_0/0.22),0_4px_8px_-4px_rgb(0_0_0/0.08)]",
        origin,
        "data-[state=open]:animate-[kit-select-in_.22s_cubic-bezier(.16,1,.3,1)_both] data-[state=closed]:animate-[kit-select-out_.12s_cubic-bezier(.16,1,.3,1)_both] motion-reduce:!animate-none",
      );
    
    const row = "flex cursor-pointer select-none items-center gap-2.5 rounded-md px-2.5 py-2 text-[14px] text-ink-2 outline-none transition-colors duration-150";
    
    function Chevron() {
      return (
        <svg
          viewBox="0 0 24 24"
          className="h-4 w-4 shrink-0 text-mute transition-transform duration-300 ease-[cubic-bezier(.16,1,.3,1)] group-data-[state=open]/sel:rotate-180"
          fill="none"
          stroke="currentColor"
          strokeWidth="2.4"
          strokeLinecap="round"
          strokeLinejoin="round"
          aria-hidden
        >
          <path d="m6 9.5 6 6 6-6" />
        </svg>
      );
    }
    
    function Check({ on }: { on: boolean }) {
      return (
        <svg viewBox="0 0 24 24" className={cx("h-4 w-4 shrink-0 text-brand transition-opacity", on ? "opacity-100" : "opacity-0")} fill="none" stroke="currentColor" strokeWidth="3" strokeLinecap="round" strokeLinejoin="round" aria-hidden>
          <path d="m5 12.5 4.5 4.5L19 7.5" />
        </svg>
      );
    }
    
    function Shown({ option, placeholder }: { option?: SelectOption; placeholder: string }) {
      return (
        <>
          {option?.icon && <span className="inline-flex shrink-0 text-ink-2 [&_svg]:h-4 [&_svg]:w-4">{option.icon}</span>}
          <span className={cx("min-w-0 flex-1 truncate", option ? "text-ink" : "text-mute")}>{option?.label ?? placeholder}</span>
        </>
      );
    }
    
    /**
     * A select. Without `searchable` it is Radix Select: arrows, Home/End, type-ahead, Escape, form support
     * and collision handling. With `searchable` it is a Radix Popover holding a filter box and a listbox.
     */
    export function Select(props: SelectProps) {
      return props.searchable ? <SearchSelect {...props} /> : <PlainSelect {...props} />;
    }
    
    function PlainSelect({ options, value, defaultValue, onChange, placeholder = "Select…", label, size = "md", name, disabled, className }: SelectProps) {
      const [inner, setInner] = useState(defaultValue);
      const current = value ?? inner;
      const selected = options.find((o) => o.value === current);
      return (
        <S.Root
          value={current ?? ""}
          onValueChange={(v) => {
            if (value === undefined) setInner(v);
            onChange?.(v);
          }}
          name={name}
          disabled={disabled}
        >
          <S.Trigger aria-label={label} className={cx(trigger(size), className)}>
            <Shown option={selected} placeholder={placeholder} />
            <S.Icon className="flex">
              <Chevron />
            </S.Icon>
          </S.Trigger>
          <S.Portal>
            <S.Content position="popper" sideOffset={6} collisionPadding={8} className={cx(panel("origin-[var(--radix-select-content-transform-origin)]"), "w-[var(--radix-select-trigger-width)]")}>
              <style href="asta-select" precedence="asta">{KEYFRAMES}</style>
              <S.Viewport className="max-h-60 [scrollbar-width:thin]">
                {options.map((o) => (
                  <S.Item key={o.value} value={o.value} disabled={o.disabled} className={cx(row, "data-[highlighted]:bg-paper-2 data-[highlighted]:text-ink data-[disabled]:cursor-not-allowed data-[disabled]:opacity-40")}>
                    {o.icon && <span className="inline-flex shrink-0 [&_svg]:h-4 [&_svg]:w-4">{o.icon}</span>}
                    <span className="min-w-0 flex-1 truncate">
                      <S.ItemText>{o.label}</S.ItemText>
                    </span>
                    {o.hint && <span className="text-[12px] text-mute">{o.hint}</span>}
                    <Check on={o.value === current} />
                  </S.Item>
                ))}
              </S.Viewport>
            </S.Content>
          </S.Portal>
        </S.Root>
      );
    }
    
    function SearchSelect({ options, value, defaultValue, onChange, placeholder = "Select…", label, size = "md", name, disabled, className }: SelectProps) {
      const [inner, setInner] = useState(defaultValue);
      const current = value ?? inner;
      const selected = options.find((o) => o.value === current);
      const [open, setOpen] = useState(false);
      const [q, setQ] = useState("");
      const [active, setActive] = useState(0);
      const search = useRef<HTMLInputElement>(null);
      const listRef = useRef<HTMLUListElement>(null);
      const uid = useId();
    
      const shown = useMemo(() => {
        const t = q.trim().toLowerCase();
        return t ? options.filter((o) => o.label.toLowerCase().includes(t)) : options;
      }, [options, q]);
    
      useEffect(() => {
        listRef.current?.querySelector<HTMLElement>(`[data-i="${active}"]`)?.scrollIntoView({ block: "nearest" });
      }, [active, open]);
    
      const show = (v: boolean) => {
        setOpen(v);
        if (v) {
          setQ("");
          setActive(Math.max(0, options.findIndex((o) => o.value === current)));
        }
      };
      const pick = (o: SelectOption | undefined) => {
        if (!o || o.disabled) return;
        if (value === undefined) setInner(o.value);
        onChange?.(o.value);
        setOpen(false);
      };
      const move = (from: number, step: number) => {
        let n = from;
        for (let k = 0; k < shown.length; k++) {
          n = Math.min(shown.length - 1, Math.max(0, n + step));
          if (!shown[n]?.disabled) break;
        }
        return n;
      };
      const onKey = (e: KeyboardEvent) => {
        if (e.key === "ArrowDown") setActive((a) => move(a, 1));
        else if (e.key === "ArrowUp") setActive((a) => move(a, -1));
        else if (e.key === "Home") setActive(move(-1, 1));
        else if (e.key === "End") setActive(move(shown.length, -1));
        else if (e.key === "Enter") pick(shown[active]);
        else return;
        e.preventDefault();
      };
    
      return (
        <Popover.Root open={open} onOpenChange={show}>
          <Popover.Trigger aria-label={label} aria-haspopup="listbox" disabled={disabled} className={cx(trigger(size), className)}>
            <Shown option={selected} placeholder={placeholder} />
            <Chevron />
          </Popover.Trigger>
          {name && <input type="hidden" name={name} value={current ?? ""} />}
          <Popover.Portal>
            <Popover.Content
              align="start"
              sideOffset={6}
              collisionPadding={8}
              onOpenAutoFocus={(e) => {
                e.preventDefault();
                search.current?.focus();
              }}
              onKeyDown={onKey}
              className={cx(panel("origin-[var(--radix-popover-content-transform-origin)]"), "w-[var(--radix-popover-trigger-width)]")}
            >
              <style href="asta-select-2" precedence="asta">{KEYFRAMES}</style>
              <div className="mb-1 flex items-center gap-2 rounded-lg bg-paper-2 px-2.5">
                <svg viewBox="0 0 24 24" className="h-3.5 w-3.5 shrink-0 text-mute" fill="none" stroke="currentColor" strokeWidth="2.4" strokeLinecap="round" strokeLinejoin="round" aria-hidden>
                  <circle cx="10.5" cy="10.5" r="6" />
                  <path d="m15 15 5 5" />
                </svg>
                <input
                  ref={search}
                  value={q}
                  onChange={(e) => {
                    setQ(e.target.value);
                    setActive(0);
                  }}
                  type="search"
                  autoComplete="off"
                  spellCheck={false}
                  placeholder="Search…"
                  aria-label="Search options"
                  role="combobox"
                  aria-expanded
                  aria-controls={`${uid}-list`}
                  aria-activedescendant={shown[active] ? `${uid}-o-${active}` : undefined}
                  className="h-9 min-w-0 flex-1 bg-transparent text-[16px] sm:text-[14px] text-ink outline-none placeholder:text-mute [&::-webkit-search-cancel-button]:hidden"
                />
              </div>
              <ul ref={listRef} id={`${uid}-list`} role="listbox" aria-label={label} className="max-h-60 overflow-y-auto outline-none [scrollbar-width:thin]">
                {shown.map((o, i) => (
                  <li
                    key={o.value}
                    id={`${uid}-o-${i}`}
                    data-i={i}
                    role="option"
                    aria-selected={o.value === current}
                    aria-disabled={o.disabled || undefined}
                    onPointerMove={() => !o.disabled && setActive(i)}
                    onClick={() => pick(o)}
                    className={cx(row, i === active && !o.disabled && "bg-paper-2 text-ink", o.disabled && "cursor-not-allowed opacity-40")}
                  >
                    {o.icon && <span className="inline-flex shrink-0 [&_svg]:h-4 [&_svg]:w-4">{o.icon}</span>}
                    <span className="min-w-0 flex-1 truncate">{o.label}</span>
                    {o.hint && <span className="text-[12px] text-mute">{o.hint}</span>}
                    <Check on={o.value === current} />
                  </li>
                ))}
                {shown.length === 0 && <li className="px-2.5 py-6 text-center text-[13px] text-mute">No matches</li>}
              </ul>
            </Popover.Content>
          </Popover.Portal>
        </Popover.Root>
      );
    }
    
    export default Select;
    
    "use client";
    
    import { Popover } from "@base-ui/react/popover";
    import { Select as S } from "@base-ui/react/select";
    import { useEffect, useId, useMemo, useRef, useState, type KeyboardEvent, type ReactNode } from "react";
    
    const cx = (...c: (string | false | null | undefined)[]) => c.filter(Boolean).join(" ");
    
    export interface SelectOption {
      value: string;
      label: string;
      icon?: ReactNode;
      hint?: string;
      disabled?: boolean;
    }
    
    export interface SelectProps {
      options: SelectOption[];
      value?: string;
      defaultValue?: string;
      onChange?: (value: string) => void;
      placeholder?: string;
      /** Adds a filter box at the top of the list. */
      searchable?: boolean;
      label?: string;
      size?: "sm" | "md";
      /** Form field name (submits the value with a form). */
      name?: string;
      disabled?: boolean;
      className?: string;
    }
    
    const trigger = (size: "sm" | "md") =>
      cx(
        "group/sel flex w-full items-center gap-2 bg-paper text-left outline-none transition-shadow duration-200 focus-visible:ring-2 focus-visible:ring-brand/50 disabled:cursor-not-allowed disabled:opacity-45",
        "shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--color-ink)_14%,transparent)] hover:shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--color-ink)_24%,transparent)]",
        "data-[popup-open]:!shadow-[inset_0_0_0_1px_var(--color-brand),0_0_0_3px_color-mix(in_srgb,var(--color-brand)_18%,transparent)]",
        size === "sm" ? "h-8 rounded-md px-2.5 text-[13px]" : "h-10 rounded-lg px-3 text-[14px]",
      );
    
    const panel = (origin: string) =>
      cx(
        "overflow-hidden rounded-xl bg-paper p-1 outline-none",
        "shadow-[0_0_0_1px_color-mix(in_srgb,var(--color-ink)_10%,transparent),0_12px_32px_-8px_rgb(0_0_0/0.22),0_4px_8px_-4px_rgb(0_0_0/0.08)]",
        origin,
        "transition-[opacity,transform] duration-[220ms] ease-[cubic-bezier(.16,1,.3,1)] data-[starting-style]:opacity-0 data-[starting-style]:[transform:translateY(-4px)_scale(.97)]",
        "data-[ending-style]:opacity-0 data-[ending-style]:scale-[.98] data-[ending-style]:duration-[120ms] data-[ending-style]:ease-[cubic-bezier(.16,1,.3,1)] motion-reduce:!transition-none",
      );
    
    const row = "flex cursor-pointer select-none items-center gap-2.5 rounded-md px-2.5 py-2 text-[14px] text-ink-2 outline-none transition-colors duration-150";
    
    function Chevron() {
      return (
        <svg
          viewBox="0 0 24 24"
          className="h-4 w-4 shrink-0 text-mute transition-transform duration-300 ease-[cubic-bezier(.16,1,.3,1)] group-data-[popup-open]/sel:rotate-180"
          fill="none"
          stroke="currentColor"
          strokeWidth="2.4"
          strokeLinecap="round"
          strokeLinejoin="round"
          aria-hidden
        >
          <path d="m6 9.5 6 6 6-6" />
        </svg>
      );
    }
    
    function Check({ on }: { on: boolean }) {
      return (
        <svg viewBox="0 0 24 24" className={cx("h-4 w-4 shrink-0 text-brand transition-opacity", on ? "opacity-100" : "opacity-0")} fill="none" stroke="currentColor" strokeWidth="3" strokeLinecap="round" strokeLinejoin="round" aria-hidden>
          <path d="m5 12.5 4.5 4.5L19 7.5" />
        </svg>
      );
    }
    
    function Shown({ option, placeholder }: { option?: SelectOption; placeholder: string }) {
      return (
        <>
          {option?.icon && <span className="inline-flex shrink-0 text-ink-2 [&_svg]:h-4 [&_svg]:w-4">{option.icon}</span>}
          <span className={cx("min-w-0 flex-1 truncate", option ? "text-ink" : "text-mute")}>{option?.label ?? placeholder}</span>
        </>
      );
    }
    
    /**
     * A select. Without `searchable` it is Base UI Select: arrows, Home/End, type-ahead, Escape, form support
     * and collision handling. With `searchable` it is a Base UI Popover holding a filter box and a listbox.
     */
    export function Select(props: SelectProps) {
      return props.searchable ? <SearchSelect {...props} /> : <PlainSelect {...props} />;
    }
    
    function PlainSelect({ options, value, defaultValue, onChange, placeholder = "Select…", label, size = "md", name, disabled, className }: SelectProps) {
      const [inner, setInner] = useState(defaultValue);
      const current = value ?? inner;
      const selected = options.find((o) => o.value === current);
      return (
        <S.Root
          value={current ?? null}
          onValueChange={(v) => {
            if (v == null) return;
            const next = String(v);
            if (value === undefined) setInner(next);
            onChange?.(next);
          }}
          name={name}
          disabled={disabled}
        >
          <S.Trigger aria-label={label} className={cx(trigger(size), className)}>
            <Shown option={selected} placeholder={placeholder} />
            <S.Icon className="flex">
              <Chevron />
            </S.Icon>
          </S.Trigger>
          <S.Portal>
            <S.Positioner alignItemWithTrigger={false} sideOffset={6} collisionPadding={8} className="z-50 outline-none">
            <S.Popup className={cx(panel("origin-[var(--transform-origin)]"), "w-[var(--anchor-width)]")}>
              <S.List className="max-h-60 overflow-y-auto outline-none [scrollbar-width:thin]">
                {options.map((o) => (
                  <S.Item key={o.value} value={o.value} disabled={o.disabled} className={cx(row, "data-[highlighted]:bg-paper-2 data-[highlighted]:text-ink data-[disabled]:cursor-not-allowed data-[disabled]:opacity-40")}>
                    {o.icon && <span className="inline-flex shrink-0 [&_svg]:h-4 [&_svg]:w-4">{o.icon}</span>}
                    <span className="min-w-0 flex-1 truncate">
                      <S.ItemText>{o.label}</S.ItemText>
                    </span>
                    {o.hint && <span className="text-[12px] text-mute">{o.hint}</span>}
                    <Check on={o.value === current} />
                  </S.Item>
                ))}
              </S.List>
            </S.Popup>
            </S.Positioner>
          </S.Portal>
        </S.Root>
      );
    }
    
    function SearchSelect({ options, value, defaultValue, onChange, placeholder = "Select…", label, size = "md", name, disabled, className }: SelectProps) {
      const [inner, setInner] = useState(defaultValue);
      const current = value ?? inner;
      const selected = options.find((o) => o.value === current);
      const [open, setOpen] = useState(false);
      const [q, setQ] = useState("");
      const [active, setActive] = useState(0);
      const search = useRef<HTMLInputElement>(null);
      const listRef = useRef<HTMLUListElement>(null);
      const uid = useId();
    
      const shown = useMemo(() => {
        const t = q.trim().toLowerCase();
        return t ? options.filter((o) => o.label.toLowerCase().includes(t)) : options;
      }, [options, q]);
    
      useEffect(() => {
        listRef.current?.querySelector<HTMLElement>(`[data-i="${active}"]`)?.scrollIntoView({ block: "nearest" });
      }, [active, open]);
    
      const show = (v: boolean) => {
        setOpen(v);
        if (v) {
          setQ("");
          setActive(Math.max(0, options.findIndex((o) => o.value === current)));
        }
      };
      const pick = (o: SelectOption | undefined) => {
        if (!o || o.disabled) return;
        if (value === undefined) setInner(o.value);
        onChange?.(o.value);
        setOpen(false);
      };
      const move = (from: number, step: number) => {
        let n = from;
        for (let k = 0; k < shown.length; k++) {
          n = Math.min(shown.length - 1, Math.max(0, n + step));
          if (!shown[n]?.disabled) break;
        }
        return n;
      };
      const onKey = (e: KeyboardEvent) => {
        if (e.key === "ArrowDown") setActive((a) => move(a, 1));
        else if (e.key === "ArrowUp") setActive((a) => move(a, -1));
        else if (e.key === "Home") setActive(move(-1, 1));
        else if (e.key === "End") setActive(move(shown.length, -1));
        else if (e.key === "Enter") pick(shown[active]);
        else return;
        e.preventDefault();
      };
    
      return (
        <Popover.Root open={open} onOpenChange={(v) => show(v)}>
          <Popover.Trigger aria-label={label} aria-haspopup="listbox" disabled={disabled} className={cx(trigger(size), className)}>
            <Shown option={selected} placeholder={placeholder} />
            <Chevron />
          </Popover.Trigger>
          {name && <input type="hidden" name={name} value={current ?? ""} />}
          <Popover.Portal>
            <Popover.Positioner align="start" sideOffset={6} collisionPadding={8} className="z-50 outline-none">
            <Popover.Popup initialFocus={search} onKeyDown={onKey} className={cx(panel("origin-[var(--transform-origin)]"), "w-[var(--anchor-width)]")}>
              <div className="mb-1 flex items-center gap-2 rounded-lg bg-paper-2 px-2.5">
                <svg viewBox="0 0 24 24" className="h-3.5 w-3.5 shrink-0 text-mute" fill="none" stroke="currentColor" strokeWidth="2.4" strokeLinecap="round" strokeLinejoin="round" aria-hidden>
                  <circle cx="10.5" cy="10.5" r="6" />
                  <path d="m15 15 5 5" />
                </svg>
                <input
                  ref={search}
                  value={q}
                  onChange={(e) => {
                    setQ(e.target.value);
                    setActive(0);
                  }}
                  type="search"
                  autoComplete="off"
                  spellCheck={false}
                  placeholder="Search…"
                  aria-label="Search options"
                  role="combobox"
                  aria-expanded
                  aria-controls={`${uid}-list`}
                  aria-activedescendant={shown[active] ? `${uid}-o-${active}` : undefined}
                  className="h-9 min-w-0 flex-1 bg-transparent text-[16px] sm:text-[14px] text-ink outline-none placeholder:text-mute [&::-webkit-search-cancel-button]:hidden"
                />
              </div>
              <ul ref={listRef} id={`${uid}-list`} role="listbox" aria-label={label} className="max-h-60 overflow-y-auto outline-none [scrollbar-width:thin]">
                {shown.map((o, i) => (
                  <li
                    key={o.value}
                    id={`${uid}-o-${i}`}
                    data-i={i}
                    role="option"
                    aria-selected={o.value === current}
                    aria-disabled={o.disabled || undefined}
                    onPointerMove={() => !o.disabled && setActive(i)}
                    onClick={() => pick(o)}
                    className={cx(row, i === active && !o.disabled && "bg-paper-2 text-ink", o.disabled && "cursor-not-allowed opacity-40")}
                  >
                    {o.icon && <span className="inline-flex shrink-0 [&_svg]:h-4 [&_svg]:w-4">{o.icon}</span>}
                    <span className="min-w-0 flex-1 truncate">{o.label}</span>
                    {o.hint && <span className="text-[12px] text-mute">{o.hint}</span>}
                    <Check on={o.value === current} />
                  </li>
                ))}
                {shown.length === 0 && <li className="px-2.5 py-6 text-center text-[13px] text-mute">No matches</li>}
              </ul>
            </Popover.Popup>
            </Popover.Positioner>
          </Popover.Portal>
        </Popover.Root>
      );
    }
    
    export default Select;
    
  4. Or ask your AI agent

    Paste this into Claude Code, Cursor, Codex, v0 or Lovable. Fill in the last line. More in Prompts.

    Add the Astabyte UI Select component to my project.
    
    A listbox with type-ahead and keys.
    It includes: search, keys, check.
    
    Install it (Radix build):
    ```sh
    pnpm dlx asta-ui@latest add select --radix
    ```
    Or with the shadcn CLI:
    ```sh
    pnpm dlx shadcn@latest add https://ui.astabyte.com/r/select.json
    ```
    If the project isn't set up yet, run `pnpm dlx asta-ui@latest init --radix` first: it runs `shadcn init` when needed and adds the @astabyte registry (Next.js, Vite, React Router, Astro, TanStack Start; Tailwind CSS v4).
    
    Import it like this:
    ```tsx
    import { Select } from "@/components/astabyte/select";
    ```
    
    Usage example and props: https://ui.astabyte.com/select
    Full catalogue for context: https://ui.astabyte.com/llms.txt
    
    Rules:
    - Keep the colour tokens (paper, paper-2, ink, ink-2, mute, brand). Don't restyle with hard-coded colours; rebrand by changing the token values in the CSS.
    - Keep the motion as it is: transform and opacity only, and the prefers-reduced-motion fallback.
    - Keep keyboard, focus and ARIA behaviour (interactive pieces are built on Radix primitives from the radix-ui package).
    - Stay on Radix: install other Astabyte UI components with `--radix` so the project uses one primitive library.
    - Use fake data and fake brand names in examples.
    
    Use it to: [describe where it goes and what it should do]
    Add the Astabyte UI Select component to my project.
    
    A listbox with type-ahead and keys.
    It includes: search, keys, check.
    
    Install it (Base UI build):
    ```sh
    pnpm dlx asta-ui@latest add select
    ```
    Or with the shadcn CLI:
    ```sh
    pnpm dlx shadcn@latest add https://ui.astabyte.com/r/base/select.json
    ```
    If the project isn't set up yet, run `pnpm dlx asta-ui@latest init` first: it runs `shadcn init` when needed and adds the @astabyte registry (Next.js, Vite, React Router, Astro, TanStack Start; Tailwind CSS v4).
    
    Import it like this:
    ```tsx
    import { Select } from "@/components/astabyte/select";
    ```
    
    Usage example and props: https://ui.astabyte.com/select
    Full catalogue for context: https://ui.astabyte.com/llms.txt
    
    Rules:
    - Keep the colour tokens (paper, paper-2, ink, ink-2, mute, brand). Don't restyle with hard-coded colours; rebrand by changing the token values in the CSS.
    - Keep the motion as it is: transform and opacity only, and the prefers-reduced-motion fallback.
    - Keep keyboard, focus and ARIA behaviour (interactive pieces are built on Base UI primitives from the @base-ui/react package).
    - Stay on Base UI: install other Astabyte UI components without `--radix` so the project uses one primitive library.
    - Use fake data and fake brand names in examples.
    
    Use it to: [describe where it goes and what it should do]
  5. Or use plain HTML + CSS

    Not on React? Use it from Django, Rails, Laravel, Go html/template, htmx or a static page. Load asta.css and asta.js once (the head.html tab), then paste the markup. The ui.astabyte.com/cdn link is temporary: pin a version from jsDelivr for production. More in HTML + CSS.

    <div class="asta-select" style="max-width:280px">
      <select class="asta-select-control" name="region" aria-label="Region">
        <option value="" disabled hidden selected>Choose a region</option>
        <option value="sin">Singapore</option>
        <option value="fra">Frankfurt</option>
        <option value="iad">Virginia</option>
      </select>
      <svg class="asta-select-icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m4 6 4 4 4-4"/></svg>
    </div>

Usage

The demo above, as code.

"use client";

import { useState } from "react";
import { Select } from "@/components/astabyte/select";

const Dot = ({ c }: { c: string }) => (
  <svg viewBox="0 0 16 16" aria-hidden>
    <circle cx="8" cy="8" r="4" fill={c} />
  </svg>
);

const TIMEZONES = [
  { value: "utc", label: "UTC", hint: "+00:00" },
  { value: "london", label: "London", hint: "+00:00" },
  { value: "berlin", label: "Berlin", hint: "+01:00" },
  { value: "dubai", label: "Dubai", hint: "+04:00" },
  { value: "jakarta", label: "Jakarta", hint: "+07:00" },
  { value: "singapore", label: "Singapore", hint: "+08:00" },
  { value: "tokyo", label: "Tokyo", hint: "+09:00" },
  { value: "sydney", label: "Sydney", hint: "+10:00" },
  { value: "new-york", label: "New York", hint: "−05:00" },
  { value: "san-francisco", label: "San Francisco", hint: "−08:00" },
];

export default function SelectDemo() {
  const [status, setStatus] = useState("progress");

  return (
    <div className="flex min-h-[420px] w-full items-start justify-center p-6 pt-16 sm:p-10 sm:pt-20">
      <div className="grid w-full max-w-lg gap-5 sm:grid-cols-2">
        <div className="flex flex-col gap-1.5">
          <span className="text-[13px] font-medium text-ink">Status</span>
          <Select
            label="Status"
            value={status}
            onChange={setStatus}
            options={[
              { value: "backlog", label: "Backlog", icon: <Dot c="color-mix(in srgb, var(--color-ink) 30%, transparent)" /> },
              { value: "progress", label: "In progress", icon: <Dot c="var(--color-ink-2)" /> },
              { value: "review", label: "In review", icon: <Dot c="var(--color-brand)" /> },
              { value: "done", label: "Done", icon: <Dot c="var(--color-ink)" /> },
              { value: "cancelled", label: "Cancelled", icon: <Dot c="var(--color-mute)" />, disabled: true },
            ]}
          />
          <span className="text-[12.5px] text-mute">Focus it and type to jump.</span>
        </div>
        <div className="flex flex-col gap-1.5">
          <span className="text-[13px] font-medium text-ink">Time zone</span>
          <Select label="Time zone" searchable placeholder="Choose a city" options={TIMEZONES} />
          <span className="text-[12.5px] text-mute">With a search box.</span>
        </div>
      </div>
    </div>
  );
}