Components

Autocomplete

Freeform text with optional suggestions. The committed value is the input text — choosing a suggestion inserts it; any typed value is valid.

Consumers supply pk-option children (or async + fetchOptions).

Prefer Autocomplete when the typed text is the value and suggestions only help complete it. Prefer Combobox when the field stores a selected option (and typing is just for filtering) — not freeform custom text.

Basic

Focus the field and type to filter, or pick a suggestion. Keep typing past a suggestion — freeform values stay committed.

Clearable

Grouped suggestions

Organize suggestions with labeled option groups when the list benefits from sections.

Async suggestions

Remote (or plugin) search via async + fetchOptions. Typing still commits freely; results only help complete the value.

With Field warning

Existence checks belong to the plugin. The field can show a soft warning while still saving a path that does not exist yet.

API

Slots

NameDescription
startPresentational decoration before the input (e.g. icons)
endPresentational decoration before the clear control
(default)pk-option and pk-option-group items

Attributes & Properties

NameDescription
ariaLabel aria-labelType string | null
Default null
asyncWhen true, options are loaded via fetchOptions as the user types instead of filtering static pk-option children.
Type boolean
Default false
autoHighlight auto-highlightWhen true, the first matching option is highlighted on open or when filtering.
Type boolean
Default false
clearableType boolean
Default false
customError custom-errorCustom validation message; also settable via setCustomValidity().
Type string | null
Default null
defaultValue default-valueType string
disabledDisables the control and excludes it from constraint validation.
Type boolean
Default false
emptyMessage empty-messageType string
Default No options found.
fetchOptionsRemote search handler — (query, signal) => Promise<options>.
Type PkAutocompleteFetchHandler | null
Default null
filterCustom filter — (option, query) => boolean. Defaults to label/value substring match.
Type PkAutocompleteFilter | null
Default null
instructionsType string
invalidType boolean
Default false
labelType string
loadingMessage loading-messageMessage shown while async results are loading.
Type string
Default Searching…
loopFocus loop-focusWhether arrow-key focus loops from the last option back to the first (and vice versa). Default: true (same as Combobox).
Type boolean
Default true
nameName submitted with form data.
Type string | null
Default null
openType boolean
Default false
placeholderEmpty by default — consumers opt in when a prompt is useful.
Type string
placementType PkPopupPlacement
Default bottom-start
requiredMarks the control as required for form submission.
Type boolean
Default false
sideOffset side-offsetGap between the control and listbox panel in px (default: 6).
Type number
Default 6
sizeType PkAutocompleteSize
Default default
startTypingMessage start-typing-messageMessage shown before the user types in async mode.
Type string
Default Start typing to search…
valueFreeform field value — always mirrors the visible input text.
Type string
widthWhen full, the control stretches to the host width.
Type 'full' | undefined
withClear with-clearType boolean
Default false

Methods

NameDescription
checkValidity()Runs constraint validation without showing the browser UI.
hide(source: PkOverlaySource)
reportValidity()Runs constraint validation and shows the browser UI when invalid.
resetValidity()Clears custom errors and re-syncs validity state.
setCustomValidity(message: string)Sets or clears a custom validation message.

Events

NameDescription
change
input
pk-change
pk-open-change

Custom States

NameDescriptionCSS selector
disabledThe control is disabled.:state(disabled)
invalidThe control currently fails constraint validation.:state(invalid)
optionalThe control is not required.:state(optional)
requiredThe control is required.:state(required)
user-invalidInvalid after the user has interacted with the control.:state(user-invalid)
user-validValid after the user has interacted with the control.:state(user-valid)
validThe control currently passes constraint validation.:state(valid)

CSS Parts

NameDescriptionCSS selector
async-statusAsync search status message::part(async-status)
clear-buttonClear value button::part(clear-button)
controlInput control wrapper::part(control)
emptyEmpty-state message::part(empty)
endHost end decoration container::part(end)
inputAutocomplete text input::part(input)
panel-bodyScrollable listbox region inside the popup panel::part(panel-body)
startHost start decoration container::part(start)

Dependencies

This component registers the following elements when it loads.

NameDescription
pk-popupPositioned suggestion panel host.
Edit this page
Last updated: Sep 15, 2026, 1:09 PM