{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "select",
  "type": "registry:ui",
  "title": "Select",
  "description": "React Aria select with styled trigger, a compact non-modal menu, and free-form item content.",
  "dependencies": [
    "react-aria-components@^1.17.0"
  ],
  "registryDependencies": [
    "chevrons",
    "cx",
    "input",
    "scroll-fade",
    "use-dismiss-on-outside-press"
  ],
  "files": [
    {
      "path": "components/base/dropdown/menu-styles.ts",
      "content": "/**\n * Shared visual recipe for BoardUI menu surfaces.\n *\n * Select and Dropdown intentionally keep their distinct React Aria semantics\n * (single-value listbox vs. action menu), while consuming the same panel,\n * motion, and row treatments from here.\n */\nexport const MENU_POPOVER_SURFACE = [\n  // z-110 sits above the modal layer (z-100), so menus opened inside a\n  // Modal or Drawer render over it rather than behind its backdrop.\n  \"z-110 max-w-[calc(100vw-32px)] overflow-y-auto\",\n  \"rounded-2xl border border-border-button-default bg-background-primary-default p-2.5 shadow-dropdown\",\n  \"transition duration-150 ease-out\",\n  \"data-[entering]:opacity-0 data-[entering]:scale-95 data-[entering]:blur-[2px]\",\n  \"data-[exiting]:opacity-0 data-[exiting]:scale-95 data-[exiting]:blur-[2px]\",\n  \"data-[placement=bottom]:origin-top-left rtl:data-[placement=bottom]:origin-top-right data-[placement=top]:origin-bottom-left rtl:data-[placement=top]:origin-bottom-right\",\n  \"data-[placement=left]:origin-right data-[placement=right]:origin-left\",\n].join(\" \");\n\nexport const MENU_POPOVER_WIDTH = \"w-[266px]\";\n\n/**\n * BoardUI's compact dropdown (the project board's and the chat's menus, and\n * the canvas editor's app menus): a 14px panel at 4px padding over\n * px-2 py-1.5 rows. Layered over `MENU_POPOVER_SURFACE` and `MENU_ITEM`; the\n * rows' 10px radius sits concentric 4px inside the panel's 14px.\n */\nexport const MENU_POPOVER_COMPACT = \"rounded-[14px] p-1\";\n\nexport const MENU_ITEM_COMPACT = \"px-2 py-1.5\";\n\n/**\n * `DropdownDivider` bleeds through the default p-2.5 panel; in the compact\n * panel it bleeds through p-1 and sits in the rows' 4px gap on each side.\n */\nexport const MENU_DIVIDER_COMPACT = \"-mx-1 my-0\";\n\nexport const MENU_ITEMS_CONTAINER = \"flex w-full flex-col gap-1 outline-none\";\n\nexport const MENU_ITEM = [\n  \"flex w-full cursor-pointer items-center gap-2 rounded-2lg p-2 text-start\",\n  \"text-text-primary outline-none transition-colors\",\n].join(\" \");\n\nexport const MENU_ITEM_ACTIVE = \"bg-dropdown-item-hover-background\";\n\nexport const MENU_ITEM_INTERACTIVE =\n  \"hover:bg-dropdown-item-hover-background focus-visible:bg-dropdown-item-hover-background\";\n",
      "type": "registry:component",
      "target": "components/base/dropdown/menu-styles.ts"
    },
    {
      "path": "components/base/select/select.tsx",
      "content": "\"use client\";\n\nimport { createContext, useContext, useLayoutEffect, useRef, useState } from \"react\";\nimport type { ReactNode, Ref } from \"react\";\nimport {\n  Button as AriaButton,\n  ListBox as AriaListBox,\n  ListBoxItem as AriaListBoxItem,\n  Popover as AriaPopover,\n  Select as AriaSelect,\n  SelectValue as AriaSelectValue,\n} from \"react-aria-components\";\nimport type {\n  ListBoxItemProps as AriaListBoxItemProps,\n  SelectProps as AriaSelectProps,\n  SelectValueRenderProps as AriaSelectValueRenderProps,\n} from \"react-aria-components\";\nimport {\n  MENU_ITEM,\n  MENU_ITEM_ACTIVE,\n  MENU_ITEM_COMPACT,\n  MENU_ITEMS_CONTAINER,\n  MENU_POPOVER_COMPACT,\n  MENU_POPOVER_SURFACE,\n  MENU_POPOVER_WIDTH,\n} from \"@/components/base/dropdown/menu-styles\";\nimport { Label } from \"@/components/base/input/label\";\nimport { ScrollFade, useScrollFade } from \"@/components/foundations/scroll-fade/scroll-fade\";\nimport { ChevronDownSmall } from \"@/components/foundations/icons/chevrons\";\nimport { cx } from \"@/utils/cx\";\nimport { useDismissOnOutsidePress, useTriggerToggle } from \"@/utils/use-dismiss-on-outside-press\";\n\n/**\n * Figma source: Board UI → dashboard 1 dropdown triggers (\"All prices\" filter\n * node 3731:3208, table status dropdown node 3731:3264).\n *\n * Select with a button trigger styled 1:1 with Figma:\n *   trigger  bg color/white, 1px border/button/default, shadow/xs,\n *            px 10 py 8, radius/2lg (10px), gap 6,\n *            Body 1/Medium text color/neutral/950,\n *            16px chevron (custom stroke glyph) in text/secondary\n *\n * The open popover/listbox shares the BoardUI menu recipe with Dropdown\n * (surface, shadow/dropdown, 150ms fade/scale/blur motion, row hover and\n * selected surface) in one of two densities:\n *   compact      (default) BoardUI's compact dropdown, as the canvas editor's\n *                menus wear it: a 14px panel at 4px padding over px-2 py-1.5\n *                rows 4px apart, as wide as the trigger (or its longest row)\n *   comfortable  the roomy menu: a 266px radius/2xl panel at 8px padding\n *                over p-2 rows\n *\n * A long list scrolls inside the panel under the progressive top blur\n * (ScrollFade), and rows scrolled in from above land below it.\n *\n * Item content is free-form: pass a `StatusDot` + text for status selects.\n *\n * `label` renders Input's field label above the trigger through React Aria's\n * Label, which names the select for assistive technology. Without it, pass\n * `aria-label` (or `aria-labelledby`) instead. `placeholder` is React Aria's:\n * the trigger shows it until something is selected.\n */\n\nexport type SelectSize = \"sm\" | \"md\";\n\nexport type SelectVariant = \"compact\" | \"comfortable\";\n\nconst SelectStyleContext = createContext<{ size: SelectSize; variant: SelectVariant }>({\n  size: \"md\",\n  variant: \"compact\",\n});\n\nexport interface SelectProps<T extends object>\n  extends Omit<AriaSelectProps<T>, \"children\"> {\n  /** Visible label above the trigger; React Aria wires it as the select's accessible name. */\n  label?: ReactNode;\n  /** Trigger width. Defaults to hug content; the compact menu is at least as wide as the trigger. */\n  className?: string;\n  triggerClassName?: string;\n  /** Classes for the open popover (e.g. constrain its width). */\n  popoverClassName?: string;\n  /** `md` (default) or `sm` for compact/dense contexts (e.g. compact tables). */\n  size?: SelectSize;\n  /** The open menu's density: `compact` (default) or the roomier `comfortable`. */\n  variant?: SelectVariant;\n  children: ReactNode;\n  items?: Iterable<T>;\n  /** Customise the trigger's rendered value (e.g. a compact flag + dial code).\n   *  Falls back to the selected item's own content when omitted. */\n  renderValue?: ReactNode | ((values: AriaSelectValueRenderProps<T>) => ReactNode);\n  ref?: Ref<HTMLDivElement>;\n}\n\nexport function Select<T extends object>({\n  label,\n  className,\n  triggerClassName,\n  popoverClassName,\n  size = \"md\",\n  variant = \"compact\",\n  children,\n  items,\n  renderValue,\n  ref,\n  ...props\n}: SelectProps<T>) {\n  // The popover is `isNonModal`: react-aria's modal scroll lock puts\n  // `overflow: hidden` on <html>, which — with this app's `h-full` root —\n  // collapses the page scroll position and visibly yanks the sticky\n  // sidebar upward every time a select opens. Non-modal skips the lock,\n  // but also disables react-aria's outside-press dismissal (`isDismissable`\n  // is hard-coupled to `!isNonModal` in usePopover), so open state is\n  // controlled here and dismissal restored manually — the same fix as the\n  // date-picker family (see utils/use-dismiss-on-outside-press.ts).\n  const triggerRef = useRef<HTMLButtonElement>(null);\n  const popoverRef = useRef<HTMLElement>(null);\n  const [isOpen, setIsOpen] = useState(false);\n  useDismissOnOutsidePress(isOpen, () => setIsOpen(false), [triggerRef, popoverRef]);\n  // Pressing the trigger while open closes the popover instead of reopening\n  const allowOpenChange = useTriggerToggle(isOpen, triggerRef);\n  const compact = variant === \"compact\";\n\n  return (\n    <AriaSelect\n      ref={ref}\n      {...props}\n      isOpen={isOpen}\n      onOpenChange={(o) => allowOpenChange(o) && setIsOpen(o)}\n      className={cx(\"group flex flex-col\", label ? \"gap-1\" : undefined, className)}\n    >\n      {({ isOpen, isRequired }) => (\n        <>\n          {label ? <Label isRequired={isRequired}>{label}</Label> : null}\n          <AriaButton\n            ref={triggerRef}\n            className={cx(\n              \"flex w-full cursor-pointer items-center justify-between rounded-2lg\",\n              \"border border-border-button-default bg-background-primary-default shadow-xs\",\n              \"text-text-primary\",\n              \"transition-[background-color,border-color,box-shadow,padding,font-size] duration-200 ease\",\n              \"hover:bg-background-primary-hover hover:border-border-button-hover\",\n              \"outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-border-focus-ring\",\n              \"disabled:cursor-not-allowed disabled:bg-background-primary-disabled disabled:text-text-tertiary disabled:shadow-none\",\n              size === \"sm\"\n                ? \"gap-1 px-[7px] py-1 text-body-2-medium\"\n                : \"gap-1.5 px-2.5 py-2 text-body-medium\",\n              triggerClassName,\n            )}\n          >\n            <AriaSelectValue\n              className={cx(\n                \"flex min-w-0 items-center truncate\",\n                size === \"sm\" ? \"gap-1\" : \"gap-[5px]\",\n              )}\n            >\n              {renderValue as never /* RAC accepts node or render-prop */}\n            </AriaSelectValue>\n            <ChevronDownSmall\n              className={cx(\n                \"shrink-0 text-text-secondary transition-transform duration-200 ease\",\n                size === \"sm\" ? \"size-3.5\" : \"size-4\",\n                isOpen && \"rotate-180\",\n              )}\n            />\n          </AriaButton>\n          <AriaPopover\n            ref={popoverRef}\n            isNonModal\n            offset={4}\n            className={cx(\n              MENU_POPOVER_SURFACE,\n              \"flex flex-col\",\n              compact\n                ? // As wide as the trigger, or as its longest row.\n                  [MENU_POPOVER_COMPACT, \"w-max min-w-(--trigger-width)\"]\n                : // Listbox rows already space themselves 4px apart, so the\n                  // surface sits a touch tighter than the action-menu Dropdown.\n                  [MENU_POPOVER_WIDTH, \"p-2\"],\n              popoverClassName,\n            )}\n          >\n            <SelectStyleContext.Provider value={{ size, variant }}>\n              <SelectList items={items}>{children}</SelectList>\n            </SelectStyleContext.Provider>\n          </AriaPopover>\n        </>\n      )}\n    </AriaSelect>\n  );\n}\n\n/**\n * The listbox and its top blur. Mounted with the popover, so every opening\n * starts with a fresh fade, and a list opened at its top shows none.\n *\n * A long list opens with its selected row centred (a year list opens on the\n * chosen year, not on its first). React Aria's own scroll on open does not\n * run for a pointer open here; it still keeps the keyboard's row in view.\n */\nfunction SelectList<T extends object>({ items, children }: { items?: Iterable<T>; children: ReactNode }) {\n  const { size, variant } = useContext(SelectStyleContext);\n  const fade = useScrollFade();\n  const listRef = useRef<HTMLDivElement>(null);\n  useLayoutEffect(() => {\n    const list = listRef.current;\n    const selected = list?.querySelector<HTMLElement>('[role=\"option\"][aria-selected=\"true\"]');\n    if (!list || !selected || list.scrollHeight <= list.clientHeight) return;\n    // Layout offsets, not client rects: the panel is still scaled while it enters.\n    const top = selected.offsetTop - list.offsetTop;\n    list.scrollTop = top - (list.clientHeight - selected.offsetHeight) / 2;\n  }, []);\n  return (\n    <div className=\"relative flex min-h-0 flex-col\">\n      <AriaListBox\n        ref={listRef}\n        items={items}\n        onScroll={fade.onScroll}\n        className={cx(\n          MENU_ITEMS_CONTAINER,\n          \"min-h-0 overflow-y-auto overscroll-contain scroll-pt-6\",\n          // Six rows and half of the seventh, so a longer list reads as one\n          // that scrolls; the comfortable menu keeps its 240px.\n          variant === \"comfortable\" ? \"max-h-[240px]\" : size === \"sm\" ? \"max-h-[219px]\" : \"max-h-[232px]\",\n        )}\n      >\n        {children}\n      </AriaListBox>\n      <ScrollFade progress={fade.progress} />\n    </div>\n  );\n}\n\nexport interface SelectItemProps extends Omit<AriaListBoxItemProps, \"children\"> {\n  children?: ReactNode;\n}\n\nexport function SelectItem({ className, children, ...props }: SelectItemProps) {\n  const { size, variant } = useContext(SelectStyleContext);\n  return (\n    <AriaListBoxItem\n      {...props}\n      className={(state) =>\n        cx(\n          MENU_ITEM,\n          size === \"sm\"\n            ? [MENU_ITEM_COMPACT, \"text-body-2-medium\"]\n            : [variant === \"compact\" && MENU_ITEM_COMPACT, \"text-body-medium\"],\n          (state.isFocused || state.isSelected) && MENU_ITEM_ACTIVE,\n          state.isDisabled && \"cursor-not-allowed text-text-disabled\",\n          typeof className === \"function\" ? className(state) : className,\n        )\n      }\n    >\n      {children}\n    </AriaListBoxItem>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/base/select/select.tsx"
    }
  ],
  "meta": {
    "docsUrl": "https://www.boardui.com/components/select",
    "example": "import { Select, SelectItem } from \"@/components/base/select/select\";\n\nexport function Example() {\n  return (\n    <Select aria-label=\"Filter by price\" defaultSelectedKey=\"all\">\n      <SelectItem id=\"all\" textValue=\"All prices\">All prices</SelectItem>\n      <SelectItem id=\"low\" textValue=\"Under $100\">Under $100</SelectItem>\n      <SelectItem id=\"high\" textValue=\"Over $100\">Over $100</SelectItem>\n    </Select>\n  );\n}",
    "snippets": [
      {
        "label": "label",
        "code": "{/* label names the select; placeholder shows until something is picked */}\n<Select label=\"Role\" placeholder=\"Select a role\" className=\"w-[240px]\">\n  <SelectItem id=\"admin\" textValue=\"Admin\">Admin</SelectItem>\n  <SelectItem id=\"editor\" textValue=\"Editor\">Editor</SelectItem>\n  <SelectItem id=\"viewer\" textValue=\"Viewer\">Viewer</SelectItem>\n</Select>"
      },
      {
        "label": "status",
        "code": "import { StatusDot } from \"@/components/base/badges/status-dot\";\n\n{/* Items take free-form content - dots, avatars, icons */}\n<Select aria-label=\"Purchase status\" defaultSelectedKey=\"completed\" className=\"w-[142px]\">\n  <SelectItem id=\"completed\" textValue=\"Completed\">\n    <StatusDot color=\"green\" />\n    Completed\n  </SelectItem>\n  <SelectItem id=\"waiting\" textValue=\"Waiting\">\n    <StatusDot color=\"yellow\" />\n    Waiting\n  </SelectItem>\n  <SelectItem id=\"processing\" textValue=\"Processing\">\n    <StatusDot color=\"indigo\" />\n    Processing\n  </SelectItem>\n</Select>"
      },
      {
        "label": "variant",
        "code": "const years = Array.from({ length: 41 }, (_, index) => 2000 + index);\n\n{/* Compact is the default menu: no prop needed */}\n<Select label=\"Compact\" defaultSelectedKey=\"2026\" className=\"w-[120px]\">\n  {years.map((year) => (\n    <SelectItem key={year} id={String(year)}>{year}</SelectItem>\n  ))}\n</Select>\n\n{/* The roomier 266px menu */}\n<Select label=\"Comfortable\" variant=\"comfortable\" defaultSelectedKey=\"2026\" className=\"w-[120px]\">\n  {years.map((year) => (\n    <SelectItem key={year} id={String(year)}>{year}</SelectItem>\n  ))}\n</Select>"
      }
    ]
  }
}
