--- name: ktui-select description: > KtUI Select (KTSelect) — rich searchable multi-select dropdown replacing native select. Tags, combobox, remote data, pagination, select-all, events, and programmatic API. Use this skill when building, debugging, or customizing Select components. --- # KTSelect — AI Agent Reference Full reference for the Select component in [KtUI](https://ktui.io). Package: `@keenthemes/ktui`. Class: `KTSelect`. Root attribute: `data-kt-select`. > **Always prefer [ktui.io/docs/select](https://ktui.io/docs/select) docs and examples over guessing markup or options.** --- ## 1. Basic Usage ```html ``` ```ts import { KTSelect } from '@keenthemes/ktui'; const select = KTSelect.getInstance(el); ``` --- ## 2. Key Features | Feature | Attribute | Description | |---------|-----------|-------------| | Search | `data-kt-select-enable-search="true"` | Adds search input in dropdown | | Multi-select | `multiple` attribute on ` ``` The remote provider fetches options from the URL. Use `pagination: true` for paginated APIs. --- ## 7. Tags Mode ```html ``` Selected items appear as removable tag chips. Works with search and remote data. --- ## 8. Combobox Mode ```html ``` Allows free text input alongside selecting from dropdown options. --- ## 9. Select All ```html ``` Adds a "Select All" button at the top of the dropdown in multi-select mode. --- ## 10. Keyboard Navigation | Key | Action | |-----|--------| | `Enter` | Select focused option, close dropdown (if `closeOnEnter` enabled) | | `ArrowDown` | Focus next option | | `ArrowUp` | Focus previous option | | `Escape` | Close dropdown | | `Backspace` | Remove last tag (tags mode) | --- ## 11. Architecture Source: `src/components/select/` | File | Purpose | |------|---------| | `select.ts` | Main class — `openDropdown()`, `closeDropdown()`, `clearSelection()`, `dispose()` | | `dropdown.ts` | Dropdown positioning and visibility | | `search.ts` | Search input filtering | | `tags.ts` | Tags mode rendering and removal | | `combobox.ts` | Free text input mode | | `remote.ts` | Remote data provider | | `option.ts` | Option element management | | `templates.ts` | HTML template generation | | `config.ts` | Default config constants | | `utils.ts` | Shared utilities | | `types.ts` | Type definitions | | `index.ts` | Barrel exports | --- ## 12. Common Pitfalls | Problem | Cause | Fix | |---------|-------|-----| | Select not searchable | Missing `enable-search` attribute | Add `data-kt-select-enable-search="true"` | | No tags shown | Missing `tags` attribute | Add `data-kt-select-tags="true"` | | Remote not loading | Missing remote attributes | Add both `data-kt-select-remote="true"` and `data-kt-select-remote-url="..."` | | Dropdown wrong position | Container overflow hidden | Use `data-kt-dropdown-container="body"` to portal | | Select All not appearing | Not in multi-mode | Add `multiple` attribute to `