Skip to main content
Version: latest
Works everywhere

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.

Live demo →

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

PropTypeDefaultRequiredDescription
idstringHTML id for the input (required for accessibility).
itemsAutocompleteItem[]Selectable options.
labelstringInput label text.
placeholderstringInput placeholder.
valuestringControlled input value.
defaultValuestringUncontrolled initial value.
disabledbooleanfalseDisable the input.
requiredbooleanfalseMark field as required.
fullWidthbooleanfalseStretch to container width.
colorVariantsAccent color variant.
helperTextstringHelper text shown below the input.
errorTextstringError message (also sets error state).
onChange(value: string) => voidCalled on text input change.
onSelectItem(item: AutocompleteItem) => voidCalled when an option is selected.
classNamestringCSS class on root element.

See src/components/autocomplete/Autocomplete.model.ts for the full AutocompleteProps type.


Design Tokens

Customise Autocomplete via CSS custom properties on :root or a scoped ancestor.

TokenDefaultDescription
--pk-autocomplete-bgvar(--pk-color-surface)Input background
--pk-autocomplete-fgvar(--pk-color-fg)Input text colour
--pk-autocomplete-fg-mutedvar(--pk-color-muted)Placeholder / hint colour
--pk-autocomplete-radiusvar(--pk-radius-pill)Input corner radius
--pk-autocomplete-shadowvar(--pk-shadow-lg)Dropdown panel shadow
--pk-autocomplete-gradient-fromvar(--pk-color-brand)Focus gradient start
--pk-autocomplete-gradient-tovar(--pk-color-accent)Focus gradient end
--pk-autocomplete-item-hover-bgvar(--pk-palette-primary-50)Item hover background
--pk-autocomplete-item-active-bgvar(--pk-palette-primary-100)Selected item background
--pk-autocomplete-dropdown-bgvar(--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

CriterionNameStatusNote
1.3.1Info and Relationships (A)✅ FulfilledSemantic structure (headings, lists, labels, landmarks) must be conveyed programmatically via HTML or ARIA.
1.3.5Identify Input Purpose (AA)🔍 Manual reviewForm fields collecting personal data must expose their purpose via the HTML autocomplete attribute.
2.1.1Keyboard (A)✅ FulfilledAll functionality must be operable via keyboard alone, without requiring specific timing.
2.1.2No Keyboard Trap (A)🔍 Manual reviewKeyboard focus must never become trapped inside a component; users must always be able to navigate away using standard keys.
2.4.3Focus Order (A)🔍 Manual reviewThe keyboard focus sequence must preserve meaning and operability in the complete page integration context.
2.4.7Focus Visible (AA)🔍 Manual reviewA visible keyboard focus indicator must be present on every interactive element. Verify against the applied product theme.
2.4.11Focus Not Obscured (Min.) (AA)🔍 Manual reviewThe focused component must not be fully hidden by sticky headers, overlays, or other positioned page elements.
3.3.1Error Identification (A)🔍 Manual reviewInput errors must be identified and described to the user in text, not by colour alone.
3.3.2Labels or Instructions (A)✅ FulfilledEvery form input requires a programmatically associated label or a visible instruction.
4.1.2Name, Role, Value (A)✅ FulfilledName, role, and state of all interactive UI components must be programmatically determinable via native HTML semantics or ARIA.
4.1.3Status Messages (AA)✅ FulfilledStatus 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


Source

src/components/autocomplete/Autocomplete.model.ts