# Definition card

A dictionary entry that sounds the word out: syllables that light as it is spoken, parts of speech as tabs, examples, similar words and where it came from.

> chatcn Pro: needs a Pro license (https://chatcn.dev/pro). Install from the `@chatcn-pro` registry with your license token; setup at https://chatcn.dev/docs/chatcn-pro.

Example: Definition card. Listen to hear it while the syllables light, switch part of speech, or follow a similar word. Preview: https://chatcn.dev/preview/definition-card-demo

## Installation

```bash
npx shadcn@latest add @chatcn-pro/definition-card
```

## Usage

```tsx
import { DefinitionCard } from "@/components/ui/chatcn/pro/definition-card"

<DefinitionCard
  word="ephemeral"
  syllables={["e", "phem", "er", "al"]}
  ipa="ɪˈfɛm(ə)rəl"
  entries={[{
    pos: "adjective",
    senses: [{ meaning: "Lasting for a very short time.", example: "Fashions are ephemeral." }],
    synonyms: ["fleeting", "transient"],
  }]}
  origin="Late 16th century: from Greek ephēmeros, “lasting only a day”."
  onLookup={(word) => lookUp(word)}
/>
```

The headword is spelt in syllables with its IPA. Listen speaks it with the browser's voice for `lang`, slowed a little, and each syllable lights in turn; speech engines don't report syllables, so the highlight keeps an even beat close to a careful reading. Parts of speech are tabs, senses are numbered with a tag such as botany and an example under each. With `onLookup`, similar and opposite words become buttons that open their own entry, which is how the demo follows fleeting to its page. `origin` and `usage` close the card; usage is a small line of how often the word appears in print between two years. With no `entries` it says nothing was found and offers `suggestions`.

## Examples

### States

Example: States. A short entry, a misspelling with suggestions, and a lookup on its way. Preview: https://chatcn.dev/preview/definition-card-states

## Props

| Prop | Type | Notes |
| --- | --- | --- |
| `word`, `syllables`, `ipa`, `lang` |  | The headword and how to say it |
| `entries` | `DefinitionEntry[]` | `{ pos, senses, synonyms?, antonyms? }` |
| `origin` | `ReactNode` | Where the word came from |
| `usage` | `{ values, from, to }` | Use over time |
| `onLookup` | `(word) => void` | Makes related words and suggestions buttons |
| `loading`, `suggestions` |  | On the way, and not found |
| `labels` | `Partial<DefinitionCardLabels>` | Every string, for translation |

## Keyboard

| Key | Action |
| --- | --- |
| Arrow left, right | Move between parts of speech |
| Enter | Listen, or look up a word |

## Accessibility

- The heading reads the word whole; the dotted spelling is hidden from screen readers.
- Parts of speech follow the tabs pattern; Listen is a toggle.
- Examples carry the entry's `lang`.

## Motion

Syllables light for 210 ms each; a new part of speech rises in. Reduced motion keeps the highlight and drops the rise.

Source: https://chatcn.dev/docs/components/definition-card