Skip to content
Sign upPro
Apps SDKTranslation cardMenu

Translation card (Pro)

ProIncluded in $99

A translation that shows its work: the source above, the result below, phrase by phrase, so pointing at any phrase lights the words it came from.

ProA note to a supplier in Monterrey. Point at a phrase to see what it came from, switch the tone, or swap.

Installation

$ pnpm dlx shadcn@latest add @chatcn-pro/translation-card

Needs chatcn Pro

This command works with a Pro license, along with every Pro component.

Or start free: sign up and get three Pro components on us, with a new one every month.

Usage

tsx
import { TranslationCard } from "@/components/ui/chatcn/pro/translation-card"

<TranslationCard
  from={{ lang: "en" }}
  to={{ lang: "es-MX" }}
  pairs={[
    { source: "Could you move the delivery", target: "¿Podría mover la entrega" },
    { source: " to Thursday morning?", target: " al jueves por la mañana?" },
  ]}
  variants={{ formal, casual }}
  onSwap={swap}
/>

Pass the text as aligned phrases, the way a model returns them when asked for a phrase map; spaces live inside the phrases. Point at a phrase in either text, or tab into the translation and use the arrow keys, and its partner lights in the other text, so a reader can check the meaning rather than trust it. variants adds a tone switch; only the phrases that changed rise in. Each side has a listen button that speaks with the browser's voice for that language, and copy takes the translation. onSwap shows the swap button; translate again and pass the new sides. Language names come from Intl.DisplayNames unless you set name.

Examples

States

ProA short phrase with no tones, Japanese with a swap, and a translation on its way.

Props

PropTypeNotes
from, toTranslationSide{ lang, name? }; lang is BCP 47
pairsTranslationPair[]{ source, target } phrases, in order
variantsRecord<string, TranslationPair[]>Tones by name; two or more show the switch
tone, defaultTone, onToneChangestringThe tone shown
onSwap() => voidShows the swap button
loadingbooleanThe source shows and the translation is a placeholder
labelsPartial<TranslationCardLabels>Every string, for translation

Keyboard

KeyAction
TabInto the translation, then on to the controls
Arrow left, rightThe previous or next phrase; its source lights

Accessibility

  • Each text carries its lang, so screen readers switch voice.
  • A focused phrase has its source as a tooltip; listen buttons are toggles named with the language.
  • While loading, a status names the wait.

Motion

Lit phrases fade their tint in 150 ms. Changed phrases fade and unblur in 320 ms on a tone switch; the swap arrow turns. Reduced motion keeps the tint and drops the rest.