Predict Example
let's create a text area to capture the user's comments. We will offer the user a bit of help to finish his/her thoughts
1'use client'2import {Predictron} from '@revivesoft/inputron';3import { useState } from 'react';4const PredictRonExample = () => {5 const handleChange = (name: string, value: string) => {6 console.log('handing change for value', value);7 }89 const [comments, setComments] = useState('');10 return (11 <Predictron name='comments' onChange={handleChange}/>12 );13}14
Selectron Example
let's create a dropdown input to recommend the best surfing spots in the world
loading...
Selected Country:
Selected Surf Spot:
1"use client";23import { SelecTron } from "@revivesoft/inputron";4import { useState ,useEffect } from "react";56export default function SelectronExample() {7 const [country, setCountry] = useState("");8 const [surfSpot, setSurfSpot] = useState("");9 // reset surfing spot when country changes10 useEffect(() => { setSurfSpot("");}, [country]);1112 return (13 <>14 <div className="space-y-4">15 <SelectronClient16 value={country}17 onValueChange={setCountry}18 prompt={`top 5 countries for surfing`}19 title={`Top Countries for surfing`}20 />2122 {country && (23 <SelectronClient24 key={country}25 value={surfSpot}26 onValueChange={setSurfSpot}27 prompt={`top 8 places to surf in ${country} only.`}28 title={`Top Surf Spots in ${country}`}29 />30 )}31 </div>s32 </>33 );34}35
Labeltron Example
Let's create a simple input field with a label that translates into 5 languages on hover. The languages are spanish, arabic , german , hindi
1"use client";23import { LabelTron } from "@revivesoft/inputron";4import { Input } from "@/components/ui/input";5import { Globe } from "lucide-react";67const LabeltronExample = () => {8 const langauges = ["es", "ar", "de", "hi"];9 return (10 <div className="flex flex-col space-y-4">11 <LabelTron12 languages={langauges}13 icon={{ className: "h-3 text-pink-500", visible: true, }}14 interval={2000}15 className="text-md font-bold ">16 First Name17 </LabelTron>18 <Input name={"name"} placeholder="John "></Input>1920 <LabelTron21 languages={langauges}22 icon={{ className: "h-3 text-pink-500", visible: true,23 iconElement: <Globe className="h-3 animate-ping ml-1" />,}}24 interval={2000}25 className="text-md font-bold ">26 Enter your e-mail address27 </LabelTron>2829 <Input name={"email"} placeholder="john@email.com"></Input>30 </div>31 );32};
TextareaTron Example
Let's create a simple text area to capture the medical condition of a patient at an clinic
1'use client'2import { submitFormAction } from '@/app/actions/example-actions';3import { TextareaTron } from "@revivesoft/inputron";4import { Rocket } from "lucide-react";5import { useState,useEffect } from "react";6import { Button } from "@/components/ui/button";78const TextareatronExample = () => {9 const [comment, setComment] = useState('I feel a little bit dizzy')10 const [originalText,setOriginalText] = useState(comment);11 const customOnChange =async (e: React.ChangeEvent<HTMLTextAreaElement>) => {12 setComment(e.target.value);13 }1415 useEffect(()=>{16 setOriginalText(comment);17 })18 return (19 <>20 <form action={submitFormAction} className="space-y-2">21 <div className="px-4 py-4 bg-white dark:bg-gray-800 w-full22 space-y-4">23 <TextareaTron24 autoFocus25 id='condition'26 name='condition'27 labelConfig={28 { content: 'Describe how you feel in simple words.29 Use your favorite language.',30 visible: true,31 style: 'text-sm font-semibold text-gray-700' }}32 placeholder="Enter your comment here"33 onChange={customOnChange}34 value={comment}35 triggerKeys={['Tab']}36 setTextValue={setComment}37 prompt='Rewrite in medical terms.'38 buttonConfiguration={{39 button_visible: true,40 text_visible: true,41 text: 'Enhance it',42 icon: <Rocket className='w-3 h-3 text-xs mr-2 ' />,43 style: 'bg-white rounded-full44 text-black p-3 h-4 text-xs45 hover:bg-pink-500 hover:text-black46 hover:text-white '47 }}48 />49 <Button type='submit'50 className='bg-blue-600 text-white items-right'>51 Submit</Button>52 <div>5354 </form>5556</>57 )58}59
TextareaTron Custom Agent Example
Let's come up with ideas for family vacations.
Custom agents are available only on business plans and above.
Agent: You are an expert family travel advisor.
Mission: Offer suggestions for family-friendly vacation activities based on the user's preferences.
1'use client'2import { submitFormAction } from '@/app/actions/example-actions';3import { TextareaTron } from "@revivesoft/inputron";4import { Rocket } from "lucide-react";5import { useState,useEffect } from "react";6import { Button } from "@/components/ui/button";78const TextareatronExample = () => {9 const [comment, setComment] = useState('I feel a little bit dizzy')10 const [originalText,setOriginalText] = useState(comment);11 const customOnChange =async (e: React.ChangeEvent<HTMLTextAreaElement>) => {12 setComment(e.target.value);13 }1415 useEffect(()=>{16 setOriginalText(comment);17 })18 return (19 <>20 <form action={submitFormAction} className="space-y-2">21 <div className="px-4 py-4 bg-white w-full space-y-4">22 <TextareaTron23 autoFocus24 id='condition'25 name='TextAreaWithCustomAgent-TravelAdvisor'26 labelConfig={27 { content: 'Describe the activities your family enjoys on vacation.',28 visible: true,29 style: 'text-sm font-semibold text-gray-700' }}30 placeholder="Enter your comment here"31 onChange={customOnChange}32 value={comment}33 agent= 'custom'34 triggerKeys={['Tab']}35 setTextValue={setComment}36 buttonConfiguration={{37 button_visible: true,38 text_visible: true,39 text: 'Generate',40 icon: <Rocket className='w-3 h-3 text-xs mr-2 ' />,41 style: 'bg-white rounded-full42 text-black p-3 h-4 text-xs43 hover:bg-pink-500 hover:text-black44 hover:text-white '45 }}46 />47 <Button type='submit'48 className='bg-blue-600 text-white items-right'>49 Submit</Button>50 <div>5152 </form>5354</>55 )56}57