Autocomplete works in both server and client environments. Always use the standard import (e.g. @prokodo/ui/autocomplete) — the library detects the runtime automatically.
Autocomplete
Autocomplete combines a text input with a filtered suggestion dropdown. Supports static option arrays, async remote loading, free-form text entry, and multi-select with chip display.
Overview
import { Autocomplete } from "@prokodo/ui/autocomplete"
;<Autocomplete
name="city"
label="City"
options={cities}
value={selectedCity}
onChange={setSelectedCity}
placeholder="Search cities…"
/>
Import
import { Autocomplete } from "@prokodo/ui/autocomplete"
CSS:
import "@prokodo/ui/autocomplete.css"
Props
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
id | string | — | ✅ | HTML id for the input (required for accessibility). |
items | AutocompleteItem[] | — | ✅ | Selectable options. |
label | string | — | — | Input label text. |
placeholder | string | — | — | Input placeholder. |
value | string | — | — | Controlled input value. |
defaultValue | string | — | — | Uncontrolled initial value. |
disabled | boolean | false | — | Disable the input. |
required | boolean | false | — | Mark field as required. |
fullWidth | boolean | false | — | Stretch to container width. |
color | Variants | — | — | Accent color variant. |
helperText | string | — | — | Helper text shown below the input. |
errorText | string | — | — | Error message (also sets error state). |
onChange | (value: string) => void | — | — | Called on text input change. |
onSelectItem | (item: AutocompleteItem) => void | — | — | Called when an option is selected. |
className | string | — | — | CSS class on root element. |
See
src/components/autocomplete/Autocomplete.model.tsfor the fullAutocompletePropstype.
Design Tokens
Customise Autocomplete via CSS custom properties on :root or a scoped ancestor.
| Token | Default | Description |
|---|---|---|
--pk-autocomplete-bg | var(--pk-color-surface) | Input background |
--pk-autocomplete-fg | var(--pk-color-fg) | Input text colour |
--pk-autocomplete-fg-muted | var(--pk-color-muted) | Placeholder / hint colour |
--pk-autocomplete-radius | var(--pk-radius-pill) | Input corner radius |
--pk-autocomplete-shadow | var(--pk-shadow-lg) | Dropdown panel shadow |
--pk-autocomplete-gradient-from | var(--pk-color-brand) | Focus gradient start |
--pk-autocomplete-gradient-to | var(--pk-color-accent) | Focus gradient end |
--pk-autocomplete-item-hover-bg | var(--pk-palette-primary-50) | Item hover background |
--pk-autocomplete-item-active-bg | var(--pk-palette-primary-100) | Selected item background |
--pk-autocomplete-dropdown-bg | var(--pk-color-surface-raised) | Dropdown background |
AIC Note
Use the standard import path in application code:
import { Autocomplete } from "@prokodo/ui/autocomplete"
No separate /client or /lazy import selection is required in consumer code.
AIC components also support a priority flag for critical above-the-fold elements.
This is most visible on Image (native preloading via <link rel="preload"> for above-the-fold content).
WCAG 2.2 Status
| Criterion | Name | Status | Note |
|---|---|---|---|
| 1.3.1 | Info and Relationships (A) | ✅ Fulfilled | Semantic structure (headings, lists, labels, landmarks) must be conveyed programmatically via HTML or ARIA. |
| 1.3.5 | Identify Input Purpose (AA) | 🔍 Manual review | Form fields collecting personal data must expose their purpose via the HTML autocomplete attribute. |
| 2.1.1 | Keyboard (A) | ✅ Fulfilled | All functionality must be operable via keyboard alone, without requiring specific timing. |
| 2.1.2 | No Keyboard Trap (A) | 🔍 Manual review | Keyboard focus must never become trapped inside a component; users must always be able to navigate away using standard keys. |
| 2.4.3 | Focus Order (A) | 🔍 Manual review | The keyboard focus sequence must preserve meaning and operability in the complete page integration context. |
| 2.4.7 | Focus Visible (AA) | 🔍 Manual review | A visible keyboard focus indicator must be present on every interactive element. Verify against the applied product theme. |
| 2.4.11 | Focus Not Obscured (Min.) (AA) | 🔍 Manual review | The focused component must not be fully hidden by sticky headers, overlays, or other positioned page elements. |
| 3.3.1 | Error Identification (A) | 🔍 Manual review | Input errors must be identified and described to the user in text, not by colour alone. |
| 3.3.2 | Labels or Instructions (A) | ✅ Fulfilled | Every form input requires a programmatically associated label or a visible instruction. |
| 4.1.2 | Name, Role, Value (A) | ✅ Fulfilled | Name, role, and state of all interactive UI components must be programmatically determinable via native HTML semantics or ARIA. |
| 4.1.3 | Status Messages (AA) | ✅ Fulfilled | Status messages (loading, success, error, progress) must reach assistive technologies without a focus change (aria-live or role='status'). |
Test coverage: 2 jest-axe assertion(s) across 4 test file(s) · 3 ARIA attribute occurrence(s) in source scan. Criteria marked 🔍 require manual verification in the final product integration and theme context.
Storybook
👉 Open Autocomplete in Storybook