Spell Out

Shows a code or reference so it can be read aloud and copied correctly: grouped, look-alikes named, NATO spelling and hidden characters flagged.

StopsBooking ref misread over the phone

Installation

pnpm dlx shadcn@latest add https://bollard-ui.vercel.app/r/spell-out.json

The files land in your project. They're yours to edit.

Usage

spell-out-usage.tsx
import { SpellOut } from "@/components/ui/spell-out"

<SpellOut label="Booking reference" value="K5O1ZB" />

What it catches

  • Look-alike characters (0/O, 1/l/I, 5/S), named
  • Non-Latin homoglyphs (Cyrillic, Greek) posing as Latin letters
  • Invisible characters and leading/trailing spaces
  • Case that matters, spoken as capital/lowercase
  • Copying the exact value instead of the grouped display

Props

SpellOut props
PropTypeDefault
value* (required)

The exact value: a booking ref, IBAN, wallet address, licence key or password.

string—
label

What it is, e.g. "Booking reference".

string—
groupSize

Characters per group. Defaults to 3 for short codes and 4 for long ones.

number—
caseSensitive

Say "capital"/"lowercase" for letters. Defaults to on when the value mixes cases, or for secrets.

boolean—
secret

Mask the value until revealed, then hide it again after `revealFor` ms.

booleanfalse
revealFor

How long a revealed secret stays visible, in ms.

number30_000
defaultView

Which view opens first.

"characters" | "phonetic""characters"
onCopied

Called after the exact value was copied.

() => void—
viewLabel

Accessible label of the view switch.

string"View"
charactersLabel

Label of the characters view.

string"Characters"
phoneticLabel

Label of the phonetic (NATO) view.

string"Read aloud"
copyLabel

Label of the copy button.

string"Copy"
copiedLabel

Announced after copying.

string"Copied"
showLabel

Label of the reveal button.

string"Show"
hideLabel

Label of the hide button.

string"Hide"
hiddenLabel

Read in place of a hidden value.

string"Hidden. Show it to spell it out."
homoglyphText

Templates: `{position}` and `{detail}` are filled in.

string"Character {position} is not a Latin “{detail}”, it only …
invisibleText

Warning for invisible characters.

string"Character {position} is an invisible {detail}."
edgeSpaceText

Warning for leading or trailing spaces.

string"Character {position} is a space at the edge, easy to los…
confusableHint

Hint explaining look-alike names.

string"Look-alike characters are named underneath."

* required. Also accepts the native props of <div> (className, aria-*, data-*…), passed through to it.

Accessibility

  • View switch uses aria-pressed buttons in a labelled group
  • Groups are a list; each has its spoken spelling for screen readers
  • Hidden values announce a hidden label; reveal is an aria-pressed toggle
  • Copy result and warnings render in polite live regions

Only what the source does. Test with your own screen reader and content before shipping.

Limitations

  • Look-alike list is a common set, not exhaustive
  • Secret mode masks visually; the value is still in the page

What it stops

Booking ref misread over the phone

Also known as

nato alphabet · spell out · pnr · booking reference · wallet address · confusable · phonetic · support call

Field type

Dependencies

Pairs well with