Xzero UI
Pro library

Tone tunerPro

A brand voice card where two sliders (formality and detail) and Friendly, Confident and Empathetic chips rewrite a customer reply. Each changed sentence crossfades in place, new words can be highlighted against the original, and Copy takes the current version.

$ pnpm dlx shadcn@4.23.0 add @xzero-ui-pro/tone-tuner
Live · keyboard ready

When to use

When not to use

Installation

Register both Xzero UI namespaces in your project's components.json:

{
  "registries": {
    "@xzero-ui": "https://mcp.xzero.co.uk/r/{name}.json",
    "@xzero-ui-pro": "https://mcp.xzero.co.uk/r/pro/{name}.json"
  }
}
npx shadcn@4.23.0 add @xzero-ui-pro/tone-tuner

Install xzero-foundation once, and import @/components/xzero/foundation.css in your app root. No Xzero token is used by this snapshot. For sample portraits, photos, fonts, or logos, download https://mcp.xzero.co.uk/install-assets.mjs and run node xzero-install-assets.mjs <receiving-project>.

Usage

import { ToneTuner } from "@/components/xzero/tone-tuner/tone-tuner";

export function ReplyTone({ draft }: { draft: string }) {
  return (
    <ToneTuner
      text={draft}
      recipient={{ name: "Sofia Ramirez", subject: "Re: Duplicate charge on INV-20481" }}
      rewrite={async ({ text, instructions }, signal) => {
        const res = await fetch("/api/rewrite", { method: "POST", body: JSON.stringify({ text, instructions }), signal });
        if (!res.ok) throw new Error("The model did not respond.");
        return (await res.json()).text;
      }}
      onRewrite={text => console.log("New version", text)}
    />
  );
}

API reference

ToneTuner

A message card with voice chips and two sliders (formality and detail). Each change triggers a debounced rewrite; changed sentences crossfade in place, added words can be highlighted against the original, and Copy takes the current version. With no props it tunes a sample billing reply with simulated rewrites.

PropTypeDefaultDescription
textstring–The original draft, the source of every rewrite. Used with rewrite. Blank lines split paragraphs; single line breaks keep lines (a sign off).
rewrite(request: ToneRewriteRequest, signal: AbortSignal) => Promise<string>–Calls your model and resolves to the rewritten plain text. The request has text, formality, detail, voice and a ready made instructions string. Superseded requests are aborted. Without it the rewrites are simulated.
valueToneSettings–Controlled tone: { formality: 0 | 1 | 2, detail: 0 | 1 | 2, voice: "neutral" | "friendly" | "confident" | "empathetic" }.
defaultValueToneSettings{ formality: 1, detail: 1, voice: "neutral" }Starting tone when uncontrolled.
onValueChange(value: ToneSettings) => void–Runs on every slider step or chip press, before the debounce.
onRewrite(text: string, value: ToneSettings) => void–Runs when a rewrite lands, with the new plain text.
onCopy(text: string) => void–Runs after Copy succeeds.
recipient{ name: string; avatar?: string; subject?: string }Sofia Ramirez sampleWho the message is for, shown in the header.
modelstring"Claude Sonnet 5.5"The model named in the status while a rewrite runs.
presetsTonePreset[]Friendly, Confident, EmpatheticVoice chips. A chip sets the voice and moves both sliders to its starting point; pressing it again returns to the neutral voice.
debounceMsnumber220Quiet time after the last change before a rewrite starts.
showChangesboolean–Controlled change highlighting. Pair with onShowChangesChange.
defaultShowChangesbooleantrueHighlights words that differ from the original draft.
onShowChangesChange(show: boolean) => void–Runs when the Changes switch flips.
autoPlaybooleantrue for the uncontrolled sampleTours the presets while the card is on screen, until the first pointer press or focus inside it.
classNamestring–Class on the card.

Keyboard interactions

KeysAction
TabMoves through the voice chips, both sliders, the Changes switch and Copy.
Enter / SpacePresses a voice chip, flips Changes, or copies.
Left / Right arrowSteps a focused slider between its three levels.
Home / EndJumps a focused slider to its first or last level.

Accessibility

Motion

Responsive behavior

Performance

Notes for AI

Also in ai

Guidance for AI tools

Tone tuner: A brand voice card where two sliders (formality and detail) and Friendly, Confident and Empathetic chips rewrite a customer reply. Each changed sentence crossfades in place, new words can be highlighted against the original, and Copy takes the current version. Follow the declared prop types and do not invent props. Keep keyboard access, reduced motion support, and both light and dark themes intact when adapting it.

Full library index: https://ui.xzero.co.uk/llms.txt

Browse all components