> ## Documentation Index
> Fetch the complete documentation index at: https://docs.twenty.com/llms.txt
> Use this file to discover all available pages before exploring further.

# الإكمال التلقائي

> اقتراح قيم أثناء كتابة المستخدم مع الحفاظ على التركيز في حقل الإدخال.

## نظرة عامة

استخدم `Autocomplete` للاقتراحات المرتبطة بحقل إدخال نصي. يحافظ حقل الإدخال على مؤشر الكتابة وتركيز لوحة المفاتيح بينما تبرز مفاتيح الأسهم الاقتراحات. استخدم [تحديد](https://docs.twenty.com/ar/ui/primitives/input/select.md) عندما يجب على المستخدم اختيار قيمة من قائمة ثابتة. يبقى [Dropdown](https://docs.twenty.com/ar/ui/components/navigation/dropdown.md) المكوّن الأعلى مستوىً للقوائم والمنتقيات.

**Light**

[مثال الإكمال التلقائي (light)](https://storybook.twenty.com/iframe.html?id=ui-input-autocomplete--display\&viewMode=story\&globals=colorScheme:light)

**Dark**

[مثال الإكمال التلقائي (dark)](https://storybook.twenty.com/iframe.html?id=ui-input-autocomplete--display\&viewMode=story\&globals=colorScheme:dark)

[Open in Storybook](https://storybook.twenty.com/?path=/story/ui-input-autocomplete--display)

## استخدام

مرر `items` إلى `Root` واعرضها عبر `List` لكي تؤدي التصفية إلى تحديث الاقتراحات المرئية. يُميّز `autoHighlight="always"` النتيجة الأولى كلما فُتحت القائمة.

```tsx theme={null}
import { Autocomplete } from 'twenty-ui/primitives/input';

const FRUITS = ['Apple', 'Banana', 'Cherry'];

export const FruitInput = () => (
  <Autocomplete.Root items={FRUITS} autoHighlight="always">
    <Autocomplete.InputGroup>
      <Autocomplete.Input aria-label="Fruit" placeholder="Search fruits" />
    </Autocomplete.InputGroup>
    <Autocomplete.Portal>
      <Autocomplete.Positioner>
        <Autocomplete.Popup>
          <Autocomplete.Empty>No fruits found</Autocomplete.Empty>
          <Autocomplete.List>
            {(fruit: string) => (
              <Autocomplete.Item key={fruit} value={fruit}>
                {fruit}
              </Autocomplete.Item>
            )}
          </Autocomplete.List>
        </Autocomplete.Popup>
      </Autocomplete.Positioner>
    </Autocomplete.Portal>
  </Autocomplete.Root>
);
```

يتحكم `value` و`onValueChange` في نص الإدخال. استخدم `defaultValue` لقيمة أولية غير متحكم بها. حالة الفتح مستقلة: استخدم `open` و`onOpenChange`، أو `defaultOpen`. يتعامل `Item.onClick` مع كل من التحديد بالمؤشر ومفتاح Enter من حقل الإدخال.

يقوم `mode="list"` بالتصفية دون تغيير نص الإدخال عند الإبراز. يوفر `mode="both"` أيضًا إكمالًا مضمنًا. يبقي `mode="inline"` كل العناصر ويوفر إكمالًا مضمنًا؛ ويبقي `mode="none"` كل العناصر دون إكمال مضمن. يمنع `readOnly` الإكمال المضمن من تغيير الإدخال.

## البنية

أبقِ الأجزاء ذات الصلة داخل `Autocomplete.Root` مُثبَّت. ركّب وجهة البوابة وغلاف التموضع والمحتوى كلًّا على حدة. يجمع `InputGroup` اختياريًا الإدخال مع عناصر التحكم المجاورة ويربط النافذة المنبثقة بتلك المجموعة.

```text theme={null}
Autocomplete.Root
├── Autocomplete.InputGroup (optional)
│   ├── Autocomplete.Input
│   ├── Autocomplete.Clear (optional)
│   └── Autocomplete.Trigger (optional)
│       └── Autocomplete.Icon (optional)
├── Autocomplete.Portal
│   ├── Autocomplete.Backdrop (optional)
│   └── Autocomplete.Positioner
│       └── Autocomplete.Popup
│           ├── Autocomplete.Arrow (optional)
│           ├── Autocomplete.Empty
│           └── Autocomplete.List
│               ├── Autocomplete.Item
│               ├── Autocomplete.Group (optional)
│               │   ├── Autocomplete.GroupLabel
│               │   └── Autocomplete.Collection
│               │       └── Autocomplete.Item
│               ├── Autocomplete.Row (optional, with Root.grid)
│               │   └── Autocomplete.Item
│               └── Autocomplete.Separator (optional)
├── Autocomplete.Status (optional)
└── Autocomplete.Value (optional)
```

| الجزء | الغرض والهدف الأصلي |
| - | - |
| `Root` | يدير قيمة الإدخال والتصفية والإبرازات وحالة الفتح. لا يعرض أي عنصر. |
| `القيمة` | يقرأ نص الإدخال عبر العناصر الأبناء أو دالة عرض. لا يعرض أي عنصر. |
| `InputGroup` | يجمع الإدخال وعناصر التحكم المجاورة. يستهدف عنصر div. |
| `إدخال` | يعرض حقل إدخال المربع المركب ويحافظ على تركيز لوحة المفاتيح. يستهدف عنصر إدخال. |
| `المشغّل` | يفتح الاقتراحات أو يغلقها. يستهدف زرًا. |
| `Icon` | يحتوي على مؤشر مشغّل. يستهدف عنصر span. |
| `مسح` | يمسح قيمة الإدخال. يستهدف زرًا. |
| `Portal` | يختار الوجهة وسياسة التثبيت. يستهدف عنصر div الخاص ببوابته. |
| `Backdrop` | يوفر تراكبًا اختياريًا أسفل النافذة المنبثقة. يستهدف عنصر div. |
| `Positioner` | يدير المرساة والمحاذاة والإزاحات ومعالجة التصادم. يستهدف عنصر div الخاص به. |
| `Popup` | يعرض محتوى الاقتراح وسلوك التركيز الاختياري. يستهدف عنصر div الخاص به. |
| `Arrow` | يوفر سهمًا اختياريًا مموضعًا داخل Popup. يستهدف عنصر div. |
| `قائمة` | يعرض العناصر المُصفّاة. يستهدف عنصر div بدور مربع قائمة أو شبكة. |
| `Item` | يعرض اقتراحًا ويتعامل مع التحديد بالمؤشر أو بلوحة المفاتيح. يستهدف عنصر div. |
| `مجموعة` | يجمع العناصر ذات الصلة. يستهدف عنصر div. |
| `GroupLabel` | يضع تسمية على مجموعته الأصلية. يستهدف عنصر div. |
| `Row` | يجمع صفًا من العناصر عند تمكين `Root.grid`. يستهدف عنصر div. |
| `Collection` | يعرض العناصر المُصفّاة عبر عنصر ابن دالة. لا يعرض أي عنصر. |
| `Separator` | يفصل العناصر أو المجموعات بصريًا. يستهدف عنصر div. |
| `فارغ` | يُعلن عند عدم توفر عناصر مطابقة. يستهدف عنصر div. |
| `الحالة` | يعلن عن التغييرات، مثل حالة التحميل غير المتزامن. يستهدف عنصر div. |

تحتفظ الأجزاء المعروضة بالسمات الأصلية والمعالجات والمراجع و`className` و`style` المستندين إلى الحالة، وتركيب `render` للعنصر/الدالة من واجهة Base UI API المثبتة. تستهدف الخصائص والمراجع الأصلية عنصر الجزء نفسه. يجب أن تمرر المكونات المخصصة الخصائص والمراجع المتوفرة. تُصدَّر خصائص الأجزاء العامة وأنواع الحالة من `twenty-ui/primitives/input`، إلى جانب إجراءات Root وأنواع تفاصيل أحداث التغيير/الإبراز.

يوفر `Autocomplete.useFilter()` المطابقة المراعية للغة لـ `contains` و`startsWith` و`endsWith`. يقرأ `Autocomplete.useFilteredItems\<TItem>()` المجموعة المُصفّاة داخليًا ضمن Root. اعتبر تلك النتيجة للقراءة فقط.

## عناصر الكائنات والعناصر المجمّعة

يمكن أن تكون العناصر سلاسل نصية أو كائنات عشوائية. استخدم `itemToStringValue` لتوفير النص المستخدم للتصفية والإكمال وإرسال النموذج. تستخدم الكائنات التي على هيئة `{ value, label }` تسميتها تلقائيًا. اعرض قيمة العنصر نفسها المتوفرة عبر Root؛ لا يلزم شكل عنصر خاص بـ Twenty أو خاصية لمساواة التحديد. يدير Autocomplete إدخال النص بدلًا من قيمة كائن محدد منفصلة.

للبيانات المجمّعة، مرر مجموعات تتضمن مصفوفة `items`. يحافظ Root على نوع العنصر لـ `itemToStringValue` و`onItemHighlighted`. اعرض العناصر الأبناء المُصفّاة لكل مجموعة عبر `Group` و`Collection`:

```tsx theme={null}
import { Autocomplete } from 'twenty-ui/primitives/input';
import { Text } from 'twenty-ui/primitives/typography';

type City = { id: number; name: string; country: string };
type CityGroup = { label: string; items: City[] };

const CITY_GROUPS: CityGroup[] = [
  {
    label: 'Europe',
    items: [
      { id: 1, name: 'Paris', country: 'France' },
      { id: 2, name: 'Lisbon', country: 'Portugal' },
    ],
  },
];

export const GroupedCityInput = () => (
  <Text
    style={{ display: 'grid', alignContent: 'start', gap: 8, width: '100%' }}
  >
    <label htmlFor="grouped-city">
      <Text render={<span />}>City</Text>
    </label>
    <Autocomplete.Root
      items={CITY_GROUPS}
      itemToStringValue={(city) => city.name}
      autoHighlight="always"
    >
      <Autocomplete.Input id="grouped-city" placeholder="Search cities" />
      <Autocomplete.Portal>
        <Autocomplete.Positioner>
          <Autocomplete.Popup>
            <Autocomplete.Empty>No matching cities</Autocomplete.Empty>
            <Autocomplete.List>
              {(group: CityGroup) => (
                <Autocomplete.Group key={group.label} items={group.items}>
                  <Autocomplete.GroupLabel>
                    {group.label}
                  </Autocomplete.GroupLabel>
                  <Autocomplete.Collection>
                    {(city: City) => (
                      <Autocomplete.Item
                        key={city.id}
                        value={city}
                        description={city.country}
                      >
                        {city.name}
                      </Autocomplete.Item>
                    )}
                  </Autocomplete.Collection>
                </Autocomplete.Group>
              )}
            </Autocomplete.List>
          </Autocomplete.Popup>
        </Autocomplete.Positioner>
      </Autocomplete.Portal>
    </Autocomplete.Root>
  </Text>
);
```

**Light**

[اقتراحات الكائنات المجمّعة (light)](https://storybook.twenty.com/iframe.html?id=ui-input-autocomplete-collections--grouped-objects\&viewMode=story\&globals=colorScheme:light)

**Dark**

[اقتراحات الكائنات المجمّعة (dark)](https://storybook.twenty.com/iframe.html?id=ui-input-autocomplete-collections--grouped-objects\&viewMode=story\&globals=colorScheme:dark)

[Open in Storybook](https://storybook.twenty.com/?path=/story/ui-input-autocomplete-collections--grouped-objects)

يوفر `Item.startIcon` و`Item.endIcon` و`Item.description` محتوى داعمًا. ركّب `Trigger` و`Clear` مع [Button](https://docs.twenty.com/ar/ui/primitives/input/button.md) من Twenty UI عبر `render`. يمكن أن يحتوي `Icon` على أيقونة من `twenty-ui/icon`. أبقِ `Status` و`Empty` مُثبَّتين أثناء تحديث العناصر الأبناء حتى تتمكن قارئات الشاشة من الإعلان عن التغييرات.

## التصفية الخارجية واقتراحات الخادم

استخدم `filteredItems` عندما يدير تطبيقك التصفية. يجب أن يحافظ على البنية المسطحة أو المجمّعة لـ `items`. يقبل `filter` دالة مطابقة مخصصة؛ ويعطّل `filter={null}` التصفية الداخلية للنتائج التي صفّاها خادم مسبقًا.

```tsx theme={null}
import { useState } from 'react';
import { Autocomplete } from 'twenty-ui/primitives/input';

const CITIES = ['Paris', 'London', 'Lisbon'];

export const CityPrefixInput = () => {
  const [value, setValue] = useState('');
  const { startsWith } = Autocomplete.useFilter();
  const filteredItems = CITIES.filter((city) => startsWith(city, value));

  return (
    <Autocomplete.Root
      items={CITIES}
      filteredItems={filteredItems}
      value={value}
      onValueChange={setValue}
      autoHighlight="always"
    >
      <Autocomplete.Input aria-label="City prefix" />
      <Autocomplete.Portal>
        <Autocomplete.Positioner>
          <Autocomplete.Popup>
            <Autocomplete.Empty>No matching cities</Autocomplete.Empty>
            <Autocomplete.List>
              {(city: string) => (
                <Autocomplete.Item key={city} value={city}>
                  {city}
                </Autocomplete.Item>
              )}
            </Autocomplete.List>
          </Autocomplete.Popup>
        </Autocomplete.Positioner>
      </Autocomplete.Portal>
    </Autocomplete.Root>
  );
};
```

أبقِ Root مُثبَّتًا عند وصول النتائج بشكل غير متزامن. تحكم في `open` بشكل مستقل كي تتمكن الاستجابة من فتح الاقتراحات مع بقاء التركيز في الإدخال. يمكن لـ `Status` مُثبَّت أن يعلن عن التحميل؛ حدّث `Empty` عندما لا تحتوي الاستجابة المكتملة على نتائج. يتولى المكوّن الأب إزالة الارتداد وإلغاء الطلبات والحماية من الاستجابات القديمة.

يتلقى `onValueChange` و`onOpenChange` تفاصيل الحدث المصدر، بما فيها `reason` و`event` الأصلي و`trigger` و`cancel()` و`allowPropagation()`. يقرر المستدعون المتحكمون أي التحديثات المطلوبة ينبغي اعتمادها. على سبيل المثال، تجاهل تغيير قيمة `escape-key` للاحتفاظ باستعلام خادم، أو تجاهل الفتح بـ `input-change` حتى وصول النتائج. يتلقى `onItemHighlighted` العنصر المكتوب الأصلي وسبب إبرازِه. يحافظ الإلغاء على دلالات Base UI المثبتة؛ ولا يستبدل سياسة الحالة المتحكم بها للتطبيق.

## تركيب الإدخال والنماذج الأصلية

يقبل `Input` ‎`size="sm"` أو `size="md"` ويستخدم الأنماط نفسها المستخدمة في [Input](https://docs.twenty.com/ar/ui/primitives/input/input.md). ركّبه مع إدخال موجود باستخدام `render`. يصبح التحكم المُركّب بعد ذلك مسؤولًا عن مظهره: لا يضيف `Input` أي أنماط لـ Input ويتجاهل `size`، لكنه يمرّر `className` والسمات الأصلية والمعالجات والمرجع وسمات الحالة الخاصة بك. مرّرها إلى عنصر الإدخال الفعلي. اعرض `Input` الخاص بـ Twenty للحفاظ على المظهر القياسي.

يوفر `InputGroup` تخطيطًا ومرساة من دون إضافة حدود لحقل الإدخال. يمكن أن يحتوي على شرائح أو يعرض غلافًا موجودًا. استخدم [InputGroup](https://docs.twenty.com/ar/ui/primitives/input/input-group.md) عبر الخاصية `render` الخاصة به عندما تحتاج المجموعة كاملةً إلى تنسيق الإدخال، كما في مثال اقتراحات الكائنات المجمّعة. يفقد `Input` بدون `render` داخله حدوده الخاصة. امنح حقل الإدخال تسمية متاحة أو ركّبه مع [Field](https://docs.twenty.com/ar/ui/primitives/input/field.md).

يحافظ Root على `name` و`form` و`disabled` و`readOnly` وسلوك النموذج الأصلي المصدر. تستهدف السمات الأصلية والمرجع الخاصان بـ Input عنصر الإدخال الخاص به. يتيح `submitOnItemClick` إرسال النموذج عند تحديد اقتراح؛ ولا يرسل الإعداد الافتراضي النموذج.

يحافظ Input على معالجة IME الأصلية في Base UI، بما في ذلك أحداث التركيب وحارس التأكيد بلوحة المفاتيح.

يحتفظ إصدار Base UI المثبت باستعلام غير متحكم به عند إعادة تعيين النموذج الأصلي. لاستعلام متحكم به، عالج `onReset` الخاص بالنموذج واستعد القيمة الأولية للتطبيق.

## الموضع ووجهة البوابة والرفض

تكون القيم الافتراضية لـ `Positioner` هي `side="bottom"` و`align="start"` و`sideOffset={8}`. يحتفظ بعقد المرساة والتموضع في Base UI المثبت، بما في ذلك مراسي العناصر/المراجع/الدوال/الافتراضية، والإزاحات الوظيفية، و`positionMethod` و`collisionBoundary` و`collisionPadding` و`collisionAvoidance` و`arrowPadding` و`sticky` و`disableAnchorTracking`. اضبط هذه الإعدادات على Positioner. يتحكم DirectionProvider في الموضع المنطقي واتجاه DOM.

يستخدم `Popup` عرض المرساة كحد أدنى لعرضه. اضبط `width` الخاص به لتوفير عرض محتوى ثابت. تستهدف خصائصه الأصلية وأنماطه وتركيب العرض والمرجع عنصر المحتوى بشكل مستقل عن Positioner وPortal. يحتفظ `initialFocus` و`finalFocus` الخاصان بـ Popup بخيارات التركيز المصدر. افتراضيًا، تبقي الاقتراحات التركيز في الإدخال.

اضبط `container` و`keepMounted` على `Portal`. يؤدي حذف الحاوية إلى استخدام وجهة ThemeProvider المقيّدة الأقرب، ثم بوابة Base UI الأصلية أو جسم المستند. تنتظر قيمة `null` صريحة دون عرض حتى يتم توفير حاوية. تمر وجهات العنصر وShadowRoot والمرجع إلى Base UI. يحتفظ مرجع غير محلول بالرجوع إلى بوابة Base UI الأصلية/الجسم.

تحافظ الوجهة المقيّدة الافتراضية على رموز CSS ونظام الألوان الخاصين بها. ترث الوجهة الصريحة CSS من نطاق DOM الفعلي الخاص بها، لذا ضعها داخل نطاق السمة المقصود أو وفر تلك الأنماط هناك. يبقى سياق React والاتجاه متاحين عبر البوابات. تحتاج أهداف ShadowRoot إلى CSS وأنماط السمة الخاصة بالمكتبة في شجرة الظل تلك.

تغيّر مفاتيح الأسهم العنصر المبرز بينما يحتفظ الإدخال بالتركيز. يحدد Enter العنصر؛ ويطلب Escape والتفاعل الخارجي الرفض باستخدام الدلالات المصدر. يمكن لضغطة خارجية تنشيط عنصر التحكم الوجهة. يمكن للمنتقيات الأعلى مستوىً أن تدير سياسة تنشيط مختلفة في محولها. استدعِ `event.preventBaseUIHandler()` في `onKeyDown` الخاص بـ Input لتجاوز المعالج المضمّن لمفتاح تتولى معالجته بنفسك. استخدم `event.preventDefault()` أيضًا عند منع الإجراء الأصلي للمتصفح.

يعرض `Root.inline` مع `open` الاقتراحات دون تجميع النافذة المنبثقة. تحتفظ العناصر المضمنة باستدعاءات تحديد `onClick` الخاصة بها، لكن المكوّن المصدر المثبت يملأ الإدخال تلقائيًا فقط عند وجود Popup الخاص به. عالج `Item.onClick` عندما ينبغي أن يحدّث التحديد المضمن النص المتحكم به. يدعم `Root.grid` و`Row` التنقل في الشبكة. تحتفظ هذه الأوضاع بواجهات API للمجموعة والعرض المصدر.

## الترحيل

غلّف Popup بـ `Autocomplete.Positioner` و`Autocomplete.Portal`. يتطلب Positioner سياق Portal؛ وتتجاهل الاقتراحات المضمنة تجميع النافذة المنبثقة بالكامل. انقل خصائص الموضع والمرساة والتصادم من Popup إلى Positioner. انقل إعدادات `container` والتثبيت إلى Portal. أبقِ العرض وأنماط المحتوى والخصائص الأصلية والمعالجات والمراجع على Popup. استخدم عنصرًا ابنًا صريحًا `Arrow` لسهم.

داخل مكونات الواجهة، أبقِ سياسة البوابة المقيّدة الحالية. لا توسع واجهة API هذه وجهات بوابة العارض أو إمكانات الهندسة والتمرير والرفض؛ إذ إن تلك الإمكانات الخاصة بالعارض لها ملكية منفصلة. تحتفظ محولات المنتقيات الإنتاجية بسير عمل التنشيط المتعمد الخاص بها.

## الإزاحة

يتم إنشاء المرجع من أنواع المكوّنات العامة. تُقبل أيضًا السمات الأصلية والأسماء المتاحة ومعالجات الأحداث على الأجزاء المعروضة.

### Autocomplete.Root

**Root.actionsRef** `RefObject\<AutocompleteRootActions | null\>`

A ref to imperative actions.

* `unmount`: Ends the closing phase of the autocomplete after an externally controlled closing animation finishes.
  Call `preventUnmountOnClose()` in `onOpenChange` first, otherwise the autocomplete completes closing on its own.
  Whether it leaves the DOM is decided by `keepMounted` on the portal.
* `close`: Closes the autocomplete imperatively when called.

**Root.autoHighlight** `boolean | "always"` (default: false)

Whether the first matching item is highlighted automatically.

* `true`: highlight after the user types and keep the highlight while the query changes.
* `'always'`: always highlight the first item.

**Root.defaultOpen** `boolean` (default: false)

Whether the popup is initially open.

To render a controlled popup, use the `open` prop instead.

**Root.defaultValue** `string | number | readonly string[]`

The uncontrolled input value of the autocomplete when it's initially rendered.

To render a controlled autocomplete, use the `value` prop instead.

**Root.disabled** `boolean` (default: false)

Whether the component should ignore user interaction.

**Root.filter** `AutocompleteRootProps\<TItem\>["filter"]`

Filter function used to match items against the input query.

**Root.filteredItems** `readonly TItem[] | readonly \{ items: readonly TItem[] \}[]`

Filtered items to display in the list.
When provided, the list uses these items instead of filtering the `items` prop internally.
When `items` is also provided, this array must preserve its flat or grouped structure.
Nullish entries are not supported, as in `items`.
Use when you want to control filtering logic externally with the `useFilter()` hook.

**Root.form** `string`

Identifies the form that owns the internal input.
Useful when the autocomplete is rendered outside the form.

**Root.grid** `boolean` (default: false)

Whether list items are presented in a grid layout.
When enabled, arrow keys navigate across rows and columns inferred from DOM rows.

**Root.highlightItemOnHover** `boolean` (default: true)

Whether moving the pointer over items should highlight them.
Disabling this prop allows CSS `:hover` to be differentiated from the `:focus` (`data-highlighted`) state.

**Root.id** `string`

The id of the component.

**Root.inline** `boolean` (default: false)

Whether the list is rendered inline without using the component's own popup.

Specify `open` unconditionally in conjunction with this prop so the list is considered
visible: `<Autocomplete.Root inline open>`

**Root.inputRef** `Ref\<HTMLInputElement\>`

A ref to the hidden input element.

**Root.items** `readonly TItem[] | readonly \{ items: readonly TItem[] \}[]`

Flat items or groups with an items array. Preserves the upstream item type; nullish entries are not supported.

**Root.itemToStringValue** `(itemValue: TItem) =\> string`

When the item values are objects (`<Autocomplete.Item value={object}>`), this function converts the object value to a string representation for both display in the input and form submission.
If the shape of the object is `{ value, label }`, the label will be used automatically without needing to specify this prop.

**Root.keepHighlight** `boolean` (default: false)

Whether the highlighted item should be preserved when the pointer leaves the list.

**Root.limit** `number` (default: -1)

The maximum number of items to display in the list.

**Root.locale** `LocalesArgument`

The locale to use for string comparison.
Defaults to the user's runtime locale.

**Root.loopFocus** `boolean` (default: true)

Whether to loop keyboard focus back to the input when the end of the list is reached while using the arrow keys. The first item can then be reached by pressing \<kbd>ArrowDown\</kbd> again from the input, or the last item can be reached by pressing \<kbd>ArrowUp\</kbd> from the input.
The input is always included in the focus loop per [ARIA Authoring Practices](https://www.w3.org/WAI/ARIA/apg/patterns/combobox/).
When disabled, focus does not move when on the last element and the user presses \<kbd>ArrowDown\</kbd>, or when on the first element and the user presses \<kbd>ArrowUp\</kbd>.

**Root.modal** `boolean` (default: false)

Determines if the popup enters a modal state when open.

* `true`: user interaction is limited to the popup: document page scroll is locked and pointer interactions on outside elements are disabled.
* `false`: user interaction with the rest of the document is allowed.

On touch devices, a `true` modal blocks outside taps but leaves the page scrollable unless the popup spans nearly the full viewport width, matching native iOS behavior.

**Root.mode** `"both" | "inline" | "list" | "none"` (default: list)

Controls how the autocomplete behaves with respect to list filtering and inline autocompletion.

* `list` (default): items are dynamically filtered based on the input value. The input value does not change based on the active item.
* `both`: items are dynamically filtered based on the input value, which will temporarily change based on the active item (inline autocompletion).
* `inline`: items are static (not filtered), and the input value will temporarily change based on the active item (inline autocompletion).
* `none`: items are static (not filtered), and the input value will not change based on the active item.

**Root.name** `string`

Identifies the field when a form is submitted.

**Root.onItemHighlighted** `(highlightedValue: TItem | undefined, eventDetails: AutocompleteRootHighlightEventDetails) =\> void`

Callback fired when an item is highlighted or unhighlighted.
Receives the highlighted item value (or `undefined` if no item is highlighted) and event details with a `reason` property describing why the highlight changed.
The `reason` can be:

* `'keyboard'`: the highlight changed due to keyboard navigation.
* `'pointer'`: the highlight changed due to pointer hovering. The event may be a `MouseEvent`
  rather than a `PointerEvent`.
* `'none'`: the highlight changed for another reason, such as typing, `autoHighlight`, the
  item list changing, or the popup opening or closing.

**Root.onOpenChange** `((open: boolean, eventDetails: AutocompleteRootOpenChangeEventDetails) =\> void)`

Event handler called when the popup is opened or closed.

**Root.onOpenChangeComplete** `((open: boolean) =\> void)`

Event handler called after any animations complete when the popup is opened or closed.

**Root.onValueChange** `((value: string, eventDetails: AutocompleteRootChangeEventDetails) =\> void)`

Event handler called when the input value of the autocomplete changes.

**Root.open** `boolean`

Whether the popup is currently open. Use when controlled.

**Root.openOnInputClick** `boolean` (default: false)

Whether the popup opens when clicking the input.

**Root.readOnly** `boolean` (default: false)

Whether the user should be unable to choose a different option from the popup.

**Root.required** `boolean` (default: false)

Whether the user must choose a value before submitting a form.

**Root.submitOnItemClick** `boolean` (default: false)

Whether clicking an item should submit the autocomplete's owning form.
By default, clicking an item via a pointer or \<kbd>Enter\</kbd> key does not submit the owning form.
Useful when the autocomplete is used as a single-field form search input.

**Root.value** `string | number | readonly string[]`

The input value of the autocomplete. Use when controlled.

**Root.virtualized** `boolean` (default: false)

Whether the items are being externally virtualized.

### Autocomplete.Value

**Value.children** `ReactNode | ((value: string) =\> ReactNode)`

Content or render function receiving the current input text.

### Autocomplete.Trigger

**Trigger.className** `string | ((state: AutocompleteTriggerState) =\> string | undefined)`

CSS class applied to the element, or a function that
returns a class based on the component's state.

**Trigger.disabled** `boolean` (default: false)

Whether the component should ignore user interaction.

**Trigger.nativeButton** `boolean` (default: true)

Whether the component renders a native `<button>` element when replacing it
via the `render` prop.
Set to `false` if the rendered element is not a button (for example, `<div>`).

**Trigger.render** `ReactElement\<unknown, string | JSXElementConstructor\<any\>\> | ComponentRenderFn\<HTMLProps, AutocompleteTriggerState\>`

Allows you to replace the component's HTML element
with a different tag, or compose it with another component.

Accepts a `ReactElement` or a function that returns the element to render.

**Trigger.style** `CSSProperties | ((state: AutocompleteTriggerState) =\> CSSProperties | undefined)`

Style applied to the element, or a function that
returns a style object based on the component's state.

### Autocomplete.InputGroup

**InputGroup.className** `string | ((state: AutocompleteInputGroupState) =\> string | undefined)`

CSS class applied to the element, or a function that
returns a class based on the component's state.

**InputGroup.render** `ReactElement\<unknown, string | JSXElementConstructor\<any\>\> | ComponentRenderFn\<HTMLProps, AutocompleteInputGroupState\>`

Allows you to replace the component's HTML element
with a different tag, or compose it with another component.

Accepts a `ReactElement` or a function that returns the element to render.

**InputGroup.style** `CSSProperties | ((state: AutocompleteInputGroupState) =\> CSSProperties | undefined)`

Style applied to the element, or a function that
returns a style object based on the component's state.

### Autocomplete.Input

**Input.className** `string | ((state: ComboboxInputState) =\> string | undefined)`

CSS class applied to the element, or a function that
returns a class based on the component's state.

**Input.disabled** `boolean` (default: false)

Whether the component should ignore user interaction.

**Input.render** `ReactElement\<unknown, string | JSXElementConstructor\<any\>\> | ComponentRenderFn\<HTMLProps, ComboboxInputState\>`

Allows you to replace the component's HTML element
with a different tag, or compose it with another component.

Accepts a `ReactElement` or a function that returns the element to render.

**Input.size** `"md" | "sm"`

Visual size of the input. Inside an InputGroup, the group size applies. Not accepted with render.

**Input.style** `CSSProperties | ((state: ComboboxInputState) =\> CSSProperties | undefined)`

Style applied to the element, or a function that
returns a style object based on the component's state.

### Autocomplete.Icon

**Icon.className** `string | ((state: ComboboxIconState) =\> string | undefined)`

CSS class applied to the element, or a function that
returns a class based on the component's state.

**Icon.render** `ReactElement\<unknown, string | JSXElementConstructor\<any\>\> | ComponentRenderFn\<HTMLProps, ComboboxIconState\>`

Allows you to replace the component's HTML element
with a different tag, or compose it with another component.

Accepts a `ReactElement` or a function that returns the element to render.

**Icon.style** `CSSProperties | ((state: ComboboxIconState) =\> CSSProperties | undefined)`

Style applied to the element, or a function that
returns a style object based on the component's state.

### Autocomplete.Clear

**Clear.className** `string | ((state: ComboboxClearState) =\> string | undefined)`

CSS class applied to the element, or a function that
returns a class based on the component's state.

**Clear.disabled** `boolean` (default: false)

Whether the component should ignore user interaction.

**Clear.keepMounted** `boolean` (default: false)

Whether the component should remain mounted in the DOM when not visible.

**Clear.nativeButton** `boolean` (default: true)

Whether the component renders a native `<button>` element when replacing it
via the `render` prop.
Set to `false` if the rendered element is not a button (for example, `<div>`).

**Clear.render** `ReactElement\<unknown, string | JSXElementConstructor\<any\>\> | ComponentRenderFn\<HTMLProps, ComboboxClearState\>`

Allows you to replace the component's HTML element
with a different tag, or compose it with another component.

Accepts a `ReactElement` or a function that returns the element to render.

**Clear.style** `CSSProperties | ((state: ComboboxClearState) =\> CSSProperties | undefined)`

Style applied to the element, or a function that
returns a style object based on the component's state.

### Autocomplete.Portal

**Portal.className** `string | ((state: ComboboxPortalState) =\> string | undefined)`

CSS class applied to the element, or a function that
returns a class based on the component's state.

**Portal.container** `HTMLElement | ShadowRoot | RefObject\<HTMLElement | ShadowRoot | null\> | null`

Portal destination. Omitted uses the scoped theme container; explicit null waits without rendering. Element, ShadowRoot and ref targets pass through to Base UI.

**Portal.keepMounted** `boolean` (default: false)

Whether to keep the portal mounted in the DOM while the popup is hidden.

**Portal.render** `ReactElement\<unknown, string | JSXElementConstructor\<any\>\> | ComponentRenderFn\<HTMLProps, ComboboxPortalState\>`

Allows you to replace the component's HTML element
with a different tag, or compose it with another component.

Accepts a `ReactElement` or a function that returns the element to render.

**Portal.style** `CSSProperties | ((state: ComboboxPortalState) =\> CSSProperties | undefined)`

Style applied to the element, or a function that
returns a style object based on the component's state.

### Autocomplete.Backdrop

**Backdrop.className** `string | ((state: ComboboxBackdropState) =\> string | undefined)`

CSS class applied to the element, or a function that
returns a class based on the component's state.

**Backdrop.render** `ReactElement\<unknown, string | JSXElementConstructor\<any\>\> | ComponentRenderFn\<HTMLProps, ComboboxBackdropState\>`

Allows you to replace the component's HTML element
with a different tag, or compose it with another component.

Accepts a `ReactElement` or a function that returns the element to render.

**Backdrop.style** `CSSProperties | ((state: ComboboxBackdropState) =\> CSSProperties | undefined)`

Style applied to the element, or a function that
returns a style object based on the component's state.

### Autocomplete.Positioner

**Positioner.align** `"center" | "end" | "start"` (default: start)

Alignment relative to the anchor. Defaults to start.

**Positioner.alignOffset** `number | OffsetFunction` (default: 0)

Additional offset along the alignment axis in pixels.
Also accepts a function that returns the offset to read the dimensions of the anchor
and positioner elements, along with its side and alignment.

The function takes a `data` object parameter with the following properties:

* `data.anchor`: the dimensions of the anchor element with properties `width` and `height`.
* `data.positioner`: the dimensions of the positioner element with properties `width` and `height`.
* `data.side`: which side of the anchor element the positioner is aligned against.
* `data.align`: how the positioner is aligned relative to the specified side.

**Positioner.anchor** `Element | VirtualElement | RefObject\<Element | null\> | (() =\> Element | VirtualElement | null) | null`

An element to position the popup against.
By default, the popup will be positioned against the trigger.

**Positioner.arrowPadding** `number` (default: 5)

Minimum distance to maintain between the arrow and the edges of the popup.

Use it to prevent the arrow element from hanging out of the rounded corners of a popup.

**Positioner.className** `string | ((state: ComboboxPositionerState) =\> string | undefined)`

CSS class applied to the element, or a function that
returns a class based on the component's state.

**Positioner.collisionAvoidance** `CollisionAvoidance`

Determines how to handle collisions when positioning the popup.

`side` controls overflow on the preferred placement axis (`top`/`bottom` or `left`/`right`):

* `'flip'`: keep the requested side when it fits; otherwise try the opposite side
  (`top` and `bottom`, or `left` and `right`).
* `'shift'`: never change side; keep the requested side and move the popup within
  the clipping boundary so it stays visible.
* `'none'`: do not correct side-axis overflow.

`align` controls overflow on the alignment axis (`start`/`center`/`end`):

* `'flip'`: keep side, but swap `start` and `end` when the requested alignment overflows.
* `'shift'`: keep side and requested alignment, then nudge the popup along the
  alignment axis to fit.
* `'none'`: do not correct alignment-axis overflow.

`fallbackAxisSide` controls fallback behavior on the perpendicular axis when the
preferred axis cannot fit:

* `'start'`: allow perpendicular fallback and try the logical start side first
  (`top` before `bottom`, or `left` before `right` in LTR).
* `'end'`: allow perpendicular fallback and try the logical end side first
  (`bottom` before `top`, or `right` before `left` in LTR).
* `'none'`: do not fallback to the perpendicular axis.

When `side` is `'shift'`, explicitly setting `align` only supports `'shift'` or `'none'`.
If `align` is omitted, it defaults to `'flip'`.

**Positioner.collisionBoundary** `Boundary` (default: clipping-ancestors)

An element or a rectangle that delimits the area that the popup is confined to.

**Positioner.collisionPadding** `Padding` (default: 5)

Additional space to maintain from the edge of the collision boundary.

**Positioner.disableAnchorTracking** `boolean` (default: false)

Whether to disable the popup from tracking any layout shift of its positioning anchor.

**Positioner.positionMethod** `"absolute" | "fixed"` (default: absolute)

Determines which CSS `position` property to use.

**Positioner.ref** `Ref\<HTMLDivElement\>`

Ref to the positioning div, separate from Popup and Portal.

**Positioner.render** `ReactElement\<unknown, string | JSXElementConstructor\<any\>\> | ComponentRenderFn\<HTMLProps, ComboboxPositionerState\>`

Allows you to replace the component's HTML element
with a different tag, or compose it with another component.

Accepts a `ReactElement` or a function that returns the element to render.

**Positioner.side** `"bottom" | "inline-end" | "inline-start" | "left" | "right" | "top"` (default: bottom)

Which side of the anchor element to align the popup against.
May automatically change to avoid collisions.

**Positioner.sideOffset** `number | OffsetFunction` (default: 8)

Distance from the anchor. Defaults to 8; supports functional offsets.

**Positioner.sticky** `boolean` (default: false)

Whether to maintain the popup in the viewport after
the anchor element was scrolled out of view.

**Positioner.style** `CSSProperties | ((state: ComboboxPositionerState) =\> CSSProperties | undefined)`

Style applied to the element, or a function that
returns a style object based on the component's state.

### Autocomplete.Popup

**Popup.className** `string | ((state: ComboboxPopupState) =\> string | undefined)`

CSS class applied to the element, or a function that
returns a class based on the component's state.

**Popup.finalFocus** `boolean | RefObject\<HTMLElement | null\> | ((closeType: InteractionType) =\> boolean | void | HTMLElement | null)`

Determines the element to focus when the popup is closed.

* `false`: Do not move focus.
* `true`: Move focus based on the default behavior (trigger or previously focused element).
* `RefObject`: Move focus to the ref element.
* `function`: Called with the interaction type (`mouse`, `touch`, `pen`, or `keyboard`).
  Return an element to focus, `true` to use the default behavior, or `false`/`undefined` to do nothing.

**Popup.initialFocus** `boolean | RefObject\<HTMLElement | null\> | ((openType: InteractionType) =\> boolean | void | HTMLElement | null)`

Determines the element to focus when the popup is opened.

* `false`: Do not move focus.
* `true`: Move focus based on the default behavior (first tabbable element or popup).
* `RefObject`: Move focus to the ref element.
* `function`: Called with the interaction type (`mouse`, `touch`, `pen`, or `keyboard`).
  Return an element to focus, `true` to use the default behavior, or `false`/`undefined` to do nothing.

**Popup.render** `ReactElement\<unknown, string | JSXElementConstructor\<any\>\> | ComponentRenderFn\<HTMLProps, ComboboxPopupState\>`

Allows you to replace the component's HTML element
with a different tag, or compose it with another component.

Accepts a `ReactElement` or a function that returns the element to render.

**Popup.style** `CSSProperties | ((state: ComboboxPopupState) =\> CSSProperties | undefined)`

Style applied to the element, or a function that
returns a style object based on the component's state.

**Popup.width** `string | number`

Width of the popup. Overrides its default minimum anchor width.

### Autocomplete.Arrow

**Arrow\.className** `string | ((state: ComboboxArrowState) =\> string | undefined)`

CSS class applied to the element, or a function that
returns a class based on the component's state.

**Arrow\.render** `ReactElement\<unknown, string | JSXElementConstructor\<any\>\> | ComponentRenderFn\<HTMLProps, ComboboxArrowState\>`

Allows you to replace the component's HTML element
with a different tag, or compose it with another component.

Accepts a `ReactElement` or a function that returns the element to render.

**Arrow\.style** `CSSProperties | ((state: ComboboxArrowState) =\> CSSProperties | undefined)`

Style applied to the element, or a function that
returns a style object based on the component's state.

### Autocomplete.List

**List.className** `string | ((state: ComboboxListState) =\> string | undefined)`

CSS class applied to the element, or a function that
returns a class based on the component's state.

**List.render** `ReactElement\<unknown, string | JSXElementConstructor\<any\>\> | ComponentRenderFn\<HTMLProps, ComboboxListState\>`

Allows you to replace the component's HTML element
with a different tag, or compose it with another component.

Accepts a `ReactElement` or a function that returns the element to render.

**List.style** `CSSProperties | ((state: ComboboxListState) =\> CSSProperties | undefined)`

Style applied to the element, or a function that
returns a style object based on the component's state.

### Autocomplete.Status

**Status.className** `string | ((state: ComboboxStatusState) =\> string | undefined)`

CSS class applied to the element, or a function that
returns a class based on the component's state.

**Status.render** `ReactElement\<unknown, string | JSXElementConstructor\<any\>\> | ComponentRenderFn\<HTMLProps, ComboboxStatusState\>`

Allows you to replace the component's HTML element
with a different tag, or compose it with another component.

Accepts a `ReactElement` or a function that returns the element to render.

**Status.style** `CSSProperties | ((state: ComboboxStatusState) =\> CSSProperties | undefined)`

Style applied to the element, or a function that
returns a style object based on the component's state.

### Autocomplete.Group

**Group.className** `string | ((state: ComboboxGroupState) =\> string | undefined)`

CSS class applied to the element, or a function that
returns a class based on the component's state.

**Group.items** `readonly any[]`

Items to be rendered within this group.
When provided, child `Collection` components will use these items.

**Group.render** `ReactElement\<unknown, string | JSXElementConstructor\<any\>\> | ComponentRenderFn\<HTMLProps, ComboboxGroupState\>`

Allows you to replace the component's HTML element
with a different tag, or compose it with another component.

Accepts a `ReactElement` or a function that returns the element to render.

**Group.style** `CSSProperties | ((state: ComboboxGroupState) =\> CSSProperties | undefined)`

Style applied to the element, or a function that
returns a style object based on the component's state.

### Autocomplete.GroupLabel

**GroupLabel.className** `string | ((state: ComboboxGroupLabelState) =\> string | undefined)`

CSS class applied to the element, or a function that
returns a class based on the component's state.

**GroupLabel.render** `ReactElement\<unknown, string | JSXElementConstructor\<any\>\> | ComponentRenderFn\<HTMLProps, ComboboxGroupLabelState\>`

Allows you to replace the component's HTML element
with a different tag, or compose it with another component.

Accepts a `ReactElement` or a function that returns the element to render.

**GroupLabel.style** `CSSProperties | ((state: ComboboxGroupLabelState) =\> CSSProperties | undefined)`

Style applied to the element, or a function that
returns a style object based on the component's state.

### Autocomplete.Item

**Item.className** `string | ((state: AutocompleteItemState) =\> string | undefined)`

CSS class applied to the element, or a function that
returns a class based on the component's state.

**Item.description** `ReactNode`

Supporting text, placed according to `descriptionPlacement`.

**Item.descriptionPlacement** `"end" | "inline"` (default: inline)

Where the description renders: inline after the content or at the end of the row.

**Item.disabled** `boolean` (default: false)

Whether the component should ignore user interaction.

**Item.endIcon** `ReactNode`

Icon rendered after the content.

**Item.index** `number`

The index of the item in the list. Improves performance when specified by avoiding the need to calculate the index automatically from the DOM.

**Item.nativeButton** `boolean` (default: false)

Whether the component renders a native `<button>` element when replacing it
via the `render` prop.
Set to `true` if the rendered element is a native button.

**Item.onClick** `((event: BaseUIEvent\<MouseEvent\<HTMLDivElement, MouseEvent\>\>) =\> void)`

An optional click handler for the item when selected.
It fires when clicking the item with the pointer, as well as when pressing `Enter` with the keyboard if the item is highlighted when the `Input` or `List` element has focus.

**Item.render** `ReactElement\<unknown, string | JSXElementConstructor\<any\>\> | ComponentRenderFn\<HTMLProps, AutocompleteItemState\>`

Allows you to replace the component's HTML element
with a different tag, or compose it with another component.

Accepts a `ReactElement` or a function that returns the element to render.

**Item.startIcon** `ReactNode`

Icon rendered before the content.

**Item.style** `CSSProperties | ((state: AutocompleteItemState) =\> CSSProperties | undefined)`

Style applied to the element, or a function that
returns a style object based on the component's state.

**Item.value** `any` (default: null)

A unique value that identifies this item.

### Autocomplete.Row

**Row\.className** `string | ((state: ComboboxRowState) =\> string | undefined)`

CSS class applied to the element, or a function that
returns a class based on the component's state.

**Row\.render** `ReactElement\<unknown, string | JSXElementConstructor\<any\>\> | ComponentRenderFn\<HTMLProps, ComboboxRowState\>`

Allows you to replace the component's HTML element
with a different tag, or compose it with another component.

Accepts a `ReactElement` or a function that returns the element to render.

**Row\.style** `CSSProperties | ((state: ComboboxRowState) =\> CSSProperties | undefined)`

Style applied to the element, or a function that
returns a style object based on the component's state.

### Autocomplete.Collection

**Collection.children** `(item: any, index: number) =\> ReactNode` *required*

Render function receiving each filtered item and its index.

### Autocomplete.Empty

**Empty.className** `string | ((state: ComboboxEmptyState) =\> string | undefined)`

CSS class applied to the element, or a function that
returns a class based on the component's state.

**Empty.render** `ReactElement\<unknown, string | JSXElementConstructor\<any\>\> | ComponentRenderFn\<HTMLProps, ComboboxEmptyState\>`

Allows you to replace the component's HTML element
with a different tag, or compose it with another component.

Accepts a `ReactElement` or a function that returns the element to render.

**Empty.style** `CSSProperties | ((state: ComboboxEmptyState) =\> CSSProperties | undefined)`

Style applied to the element, or a function that
returns a style object based on the component's state.

### Autocomplete.Separator

**Separator.className** `string | ((state: AutocompleteSeparatorState) =\> string | undefined)`

CSS class applied to the element, or a function that
returns a class based on the component's state.

**Separator.orientation** `"horizontal" | "vertical"` (default: horizontal)

The orientation of the separator.

**Separator.render** `ReactElement\<unknown, string | JSXElementConstructor\<any\>\> | ComponentRenderFn\<HTMLProps, AutocompleteSeparatorState\>`

Allows you to replace the component's HTML element
with a different tag, or compose it with another component.

Accepts a `ReactElement` or a function that returns the element to render.

**Separator.style** `CSSProperties | ((state: AutocompleteSeparatorState) =\> CSSProperties | undefined)`

Style applied to the element, or a function that
returns a style object based on the component's state.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.