emoteer

EmoteAutocomplete

Inline shortcode suggestions triggered by typing `:` in any input

EmoteAutocomplete wraps any input and triggers a suggestion list when the user types :shortcode. Arrow keys, Tab and Enter select; Escape dismisses.

Value: (empty)

Anatomy

<EmoteAutocomplete.Root onSelect={...}>
  <EmoteAutocomplete.Input />
  <EmoteAutocomplete.Content>
    <EmoteAutocomplete.List />
  </EmoteAutocomplete.Content>
</EmoteAutocomplete.Root>

Basic usage

components/composer.tsx
import { EmoteAutocomplete } from '@emoteer/react';
import { useState } from 'react';

export function Composer() {
  const [value, setValue] = useState('');

  return (
    <EmoteAutocomplete.Root onSelect={(_, next) => setValue(next)}>
      <EmoteAutocomplete.Input
        value={value}
        onChange={(e) => setValue(e.target.value)}
        placeholder="Type :grin for suggestions…"
      />
      <EmoteAutocomplete.Content>
        <EmoteAutocomplete.List />
      </EmoteAutocomplete.Content>
    </EmoteAutocomplete.Root>
  );
}

Slots

SlotDescription
RootContext provider. Handles keyboard and selection.
InputText input that emits change events and triggers suggestions.
ContentPopover container positioned below the input.
ListSuggestion list. Renders matched emojis with shortcodes.

Props

EmoteAutocomplete.Root

PropTypeDescription
onSelect(emote: Emote, nextValue: string) => voidCalled when a suggestion is chosen. The second argument is the final input value with the native unicode inserted (or :name: preserved for local emotes).

EmoteAutocomplete.Input

Extends the standard <input> element. Controlled via value and onChange. Any native <input> prop is forwarded.

PropTypeDescription
classNamestringForwarded to the <input> element.
...native—All standard <input> attributes.

EmoteAutocomplete.Content

Portal-rendered floating container. Only mounts while the suggestion list is open.

PropTypeDescription
childrenReactNodeTypically an EmoteAutocomplete.List.
classNamestringForwarded to the floating element.

EmoteAutocomplete.List

Renders the matched suggestions.

PropTypeDescription
classNamestringForwarded to the listbox element.

Trigger behavior

  • Typing : opens the suggestion list.
  • Matches are based on shortcode prefix and category metadata.
  • Tab / Enter inserts the selected emoji; :shortcode: in the text is replaced with the unicode character.
  • Escape closes the list without inserting.

On this page