Skip to content

prosekit/preact/autocomplete

import {
  AutocompleteEmpty,
  AutocompleteItem,
  AutocompletePopup,
  AutocompletePositioner,
  AutocompleteRoot,
} from 'prosekit/preact/autocomplete'

<AutocompleteRoot>
  <AutocompletePositioner>
    <AutocompletePopup>
      <AutocompleteItem>...</AutocompleteItem>
      <AutocompleteEmpty>...</AutocompleteEmpty>
    </AutocompletePopup>
  </AutocompletePositioner>
</AutocompleteRoot>

Props for the AutocompleteEmpty Preact component.


Props for the AutocompleteItem Preact component.

value?: string

The value of the item, which will be matched against the query.

If not provided, the value is the item's text content.

""

disabled?: boolean

Whether this option is disabled.

false

onSelect?: (event: SelectEvent) => void

Emitted when the the item is selected.


Props for the AutocompletePopup Preact component.

onValueChange?: (event: ValueChangeEvent) => void

Emitted when the selected value changes. Only available when multiple is false.

onValuesChange?: (event: ValuesChangeEvent) => void

Emitted when the selected values change. Only available when multiple is true.


Props for the AutocompletePositioner Preact component.

placement?: Placement

The placement of the popover, relative to the text cursor.

"bottom-start"

offset?: OffsetOptions

The distance between the popover and the hovered block.

4

inline?: boolean

true

hoist?: boolean

true

fitViewport?: boolean

true

boundary?: Boundary

"The body element"

overflowPadding?: number

8

strategy?: "fixed" | "absolute"

The strategy to use for positioning

"absolute"

autoUpdate?: boolean | AutoUpdateOptions

Options to activate auto-update listeners

https://floating-ui.com/docs/autoUpdate

true

flip?: boolean | Placement[]

Whether to flip the placement in order to keep it in view when the preferred placement(s) will overflow the clipping boundary. You can also provide an array of placements to try sequentially if the preferred placement does not fit.

true

shift?: boolean

Whether the floating element should shift to keep it in view.

true

overlap?: boolean

Whether the floating element can overlap the reference element to keep it in view.

false

sameWidth?: boolean

Whether to constrain the floating element's width so that it matches the reference element.

false

sameHeight?: boolean

Whether to constrain the floating element's height so that it matches the reference element.

false

hide?: boolean

Whether to hide the floating element when the reference element or the floating element is fully clipped.

false

rootBoundary?: RootBoundary

Describes the root boundary that the element will be checked for overflow relative to. Please see https://floating-ui.com/docs/detectoverflow#rootboundary for more information.

'viewport'

elementContext?: ElementContext

The element that will be used to check for overflow. Please see https://floating-ui.com/docs/detectoverflow#elementcontext for more information.

'floating'

altBoundary?: boolean

Whether to check the alternate elementContext's boundary. Please see https://floating-ui.com/docs/detectoverflow#altboundary for more information.

false


Props for the AutocompleteRoot Preact component.

regex?: RegExp | null

The regular expression to match the query text to autocomplete.

null

filter?: ItemFilter | null

The filter function to determine if an item should be shown in the listbox.

defaultItemFilter

onOpenChange?: (event: OpenChangeEvent) => void

Fired when the open state changes.

onQueryChange?: (event: QueryChangeEvent) => void

Fired when the query changes.

onValueChange?: (event: ValueChangeEvent) => void

Emitted when the selected value changes. Only available when multiple is false.

onValuesChange?: (event: ValuesChangeEvent) => void

Emitted when the selected values change. Only available when multiple is true.

const AutocompleteEmpty: ForwardRefExoticComponent<AutocompleteEmptyProps & HTMLAttributes<AutocompleteEmptyElement> & RefAttributes<AutocompleteEmptyElement>>

A Preact component that renders an prosekit-autocomplete-empty custom element.


const AutocompleteItem: ForwardRefExoticComponent<AutocompleteItemProps & Omit<HTMLAttributes<AutocompleteItemElement>, "onSelect"> & RefAttributes<AutocompleteItemElement>>

A Preact component that renders an prosekit-autocomplete-item custom element.


const AutocompletePopup: ForwardRefExoticComponent<AutocompletePopupProps & HTMLAttributes<AutocompletePopupElement> & RefAttributes<AutocompletePopupElement>>

A Preact component that renders an prosekit-autocomplete-popup custom element.


const AutocompletePositioner: ForwardRefExoticComponent<AutocompletePositionerProps & HTMLAttributes<AutocompletePositionerElement> & RefAttributes<AutocompletePositionerElement>>

A Preact component that renders an prosekit-autocomplete-positioner custom element.


const AutocompleteRoot: ForwardRefExoticComponent<AutocompleteRootProps & HTMLAttributes<AutocompleteRootElement> & RefAttributes<AutocompleteRootElement>>

A Preact component that renders an prosekit-autocomplete-root custom element.