smart-components
Components

SmartParaphraseBox

Single-line input with a built-in sparkle button that paraphrases on tap.

Ready-made input that wraps SmartRewrite with a paraphrase button. Tap the button to rewrite in place. Auto-accepts when complete (configurable via onRewriteAccept).

Preview

Tap the sparkle button to rewrite.

import { useState } from 'react';import { SmartProvider, SmartParaphraseBox } from '@extedcoud/smart-components';import { createMockClient } from '@extedcoud/smart-components/adapters/mock';const client = createMockClient({complete: async (req) => 'Please let me know if there is anything else you need.',});export function Example() {const [value, setValue] = useState('lemme know if you need anything else');return (  <SmartProvider client={client}>    <SmartParaphraseBox      value={value}      onChange={setValue}      instruction="Rewrite in a polished, professional tone."    />  </SmartProvider>);}

Styled example

A pill input with a gradient border and a circular violet→fuchsia sparkle button.

Tap ✦ to polish to a professional tone.

'use client';import { useState } from 'react';import { SmartProvider, SmartParaphraseBox } from '@extedcoud/smart-components';import { makeRewriteMock } from '@/lib/mock-client';const client = makeRewriteMock();export default function SmartParaphraseBoxStylized() {  const [value, setValue] = useState('lemme know if you need anything else');  return (    <SmartProvider client={client}>      <div className="w-full max-w-md">        <div className="rounded-2xl bg-gradient-to-r from-fuchsia-500 via-violet-500 to-indigo-500 p-[1.5px] shadow-lg shadow-violet-500/15">          <div className="rounded-[14px] bg-fd-card">            <SmartParaphraseBox              value={value}              onChange={setValue}              instruction="Rewrite this text in a polished, professional tone. Keep the same meaning."              wrapperClassName="flex items-center gap-2 px-3 py-2"              className="flex-1 bg-transparent text-base text-fd-foreground outline-none placeholder:text-fd-muted-foreground"              buttonClassName="inline-flex h-9 min-h-[44px] w-9 items-center justify-center rounded-full bg-gradient-to-br from-fuchsia-500 to-violet-500 text-white shadow transition hover:scale-105 disabled:opacity-50"              buttonAriaLabel="Polish text"            />          </div>        </div>        <p className="mt-2 px-1 text-xs text-fd-muted-foreground">          Tap ✦ to polish to a professional tone.        </p>      </div>    </SmartProvider>  );}

Custom button

<SmartParaphraseBox
  value={v}
  onChange={setV}
  renderButton={({ onClick, status, disabled }) => (
    <button onClick={onClick} disabled={disabled}>
      {status === 'loading' ? '…' : 'Rewrite'}
    </button>
  )}
/>

Streaming first paint

<SmartParaphraseBox value={v} onChange={setV} stream />

While streaming, the input shows the partial rewrite (read-only) — accepted automatically on complete.

Props

PropTypeDefaultDescription
value*stringControlled input value.
onChange*(value: string) => voidCalled on user input and when a rewrite is accepted.
contextstringOptional context string included in the prompt.
instructionstringDefault rewrite instruction.
streambooleanfalseUse the streaming capability for faster first paint.
maxTokensnumber256Max tokens for the rewrite call.
temperaturenumber0.4Sampling temperature.
disableAIbooleanfalseHide the button and no-op imperative rewrite().
iconReactNodeCustom icon for the button. Defaults to a built-in sparkle SVG.
buttonAriaLabelstring'Paraphrase'Accessible label for the button.
buttonClassNamestringClass name applied to the button.
buttonStyleCSSPropertiesInline style applied to the button.
renderButton(args: ParaphraseButtonRenderArgs) => ReactNodeFull custom render for the button.
wrapperClassNamestringClass name applied to the outer wrapper.
onRewriteStart() => voidCalled when a rewrite starts.
onRewriteAccept(rewrite: string) => voidCalled when a rewrite is accepted, with the rewritten text.
onRewriteError(error: Error) => voidCalled when a rewrite errors.
...restInputHTMLAttributes<HTMLInputElement>All native input props minus value, onChange, defaultValue.