PredictiveText
The PredictiveText
component is a React functional component that provides predictive text suggestions based on user input. It handles various states such as loading, error, and displaying predicted text.
Props
name
- Type:
string
- Description: The name identifier for the input field.
onChange
- Type:
(name: string, value: string) => void
- Description: Callback function that is triggered when the input value changes.
loaderOptions
- Type:
object
- Description: Configuration options for the loader.
visible
(optional):boolean
- Whether the loader is visible.className
(optional):string
- Additional class names for the loader.
triggerInterval
- Type:
number
- Description: The interval in milliseconds at which the predictive text action is triggered.
...props
- Type:
React.InputHTMLAttributes<HTMLInputElement>
- Description: Additional HTML attributes to be passed to the input element.
Example Usage
'use client'
import { Predictron} from "@revivesoft/inputron";
import { useState } from 'react';
const PredictRonExample = () => {
const handleChange = (name: string, value: string) => {
console.log('handing change for value', value);
setComments(value);
console.log('comments', comments);
}
const [comments, setComments] = useState('');
return (
<Predictron name='comments' onChange={handleChange}/>
);
}