Skip to main content
The library provides a React hook to easily integrate Singlish typing into your React applications.

useSinglishConverter

A hook that manages the state of a textarea input, handling cursor position, selection, and Singlish conversion automatically.

Parameters

options (UseSinglishConverterOptions, optional):

Return Value

The hook returns an object with the following properties:
  • inputProps: An object containing props to spread onto a <textarea> or <input>.
    • value: The current value (controlled).
    • onChange: Handler for text changes.
    • onKeyDown: Handler for key presses (Singlish logic).
    • onPaste: Handler for pasting.
  • value (string): The current text value.
  • setValue ((value: string) => void): Function to programmatically set the value.
  • enabled (boolean): Whether Singlish conversion is currently active.
  • toggle (() => void): Function to toggle Singlish on/off.
  • setEnabled ((enabled: boolean) => void): Function to set the enabled state explicitly.
  • convertAll (() => void): Function to convert the entire text content at once.
  • clear (() => void): Function to clear the input.
  • bufferDisplay (string): Current raw IME buffer (useful for debug UI).
  • focus (() => void): Focuses the bound textarea.
  • flushPending (() => string): Commits pending IME buffer.

Example