SMS Segments

SMS Segments is a copy-paste React component that stops one emoji doubled the sms bill before the user submits. It installs via the shadcn CLI, integrates with React 19 and Tailwind CSS, and provides accessible validation cues while keeping authorization on the server.

pnpm dlx shadcn@latest add @bollard/sms-segments
Version 0.1.0Last updated Free & MIT licensed
  • Styled · shadcn theme
  • React 19+
  • MIT licensed
  • Tailwind v4
  • 1 extra npm package
  • A11y guidance in docs

StopsOne emoji doubled the SMS bill

Was this component page useful?

How do I install SMS Segments?

pnpm dlx shadcn@latest add @bollard/sms-segments

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

How do I use SMS Segments in React?

sms-segments-usage.tsx
import { SmsSegments } from "@/components/ui/sms-segments"

<SmsSegments rows={5} label="Order update SMS" defaultValue={draft} recipients={recipients} pricePerSegment={0.2} currency="INR" locale="en-IN" />

What input mistakes does SMS Segments catch?

  • Characters outside GSM-7 that force UCS-2 (curly quotes, emoji, look-alikes)
  • Extension characters (€, [, ~) that use two septets
  • Part count and cost per recipient count
  • Never splits a 2-septet character or surrogate pair across parts
  • One-tap replace or remove of each culprit

What props does SMS Segments accept?

SmsSegments props
PropTypeDefault
label

Visible label.

string"Message"
value

Controlled text.

string—
defaultValue

Initial text when uncontrolled.

string""
onValueChange

Called on every edit, including one-tap fixes.

(value: string) => void—
recipients

How many people receive it; every part is billed per recipient.

number1
pricePerSegment

Price of one part to one recipient. Omit to hide money and show message counts only.

number—
currency

ISO currency code for the price.

string"USD"
locale

Locale for numbers and money; defaults to the browser's.

string—
oneCulpritMessage

Shown when one character is the cause. `{name}` ("curly apostrophe"), `{char}`, `{count}`, `{plain}` are filled in.

string"The {name} ({char}) makes it {count} instead of {plain}."
manyCulpritsMessage

Shown when several characters are the cause.

string"These characters make it {count} instead of {plain}."
freeUnicodeMessage

Shown when Unicode costs nothing extra yet.

string"Sent as Unicode because of the {name} ({char}). Still {c…
fixAllLabel

Label of the button that fixes every culprit at once.

string"Fix all"
replaceLabel

Accessible names of the one-tap fixes; `{name}` and `{to}` are filled in.

string"Replace {name} with {to}"
removeLabel

Accessible label of a remove-character fix. `{name}` is filled in.

string"Remove {name}"
removeText

Shown in a fix chip when the character is simply dropped.

string"remove"
messageText

Message counts: `{n}` is filled in.

string"{n} message"
messagesText

Count label for several messages.

string"{n} messages"
partsLabel

Accessible name of the part meter, and its captions. `{capacity}` and `{left}` are filled in.

string"Message parts"
perPartText

Per-part capacity text.

string"{capacity} per part · tap a part to see it"
onePartText

Shown when the text fits one part.

string"{capacity} fit in one message"
leftText

Characters left in the current part.

string"{left} left"
costText

Cost readback: `{messages}`, `{recipients}`, `{sms}` and `{price}` are filled in.

string"{messages} × {recipients} = {sms} SMS"
pricedCostText

Total cost line when a price is set.

string"{messages} × {recipients} = {sms} SMS · {price}"
fixedText

Saving after the fix: `{sms}` and `{saving}` are filled in.

string"Fixed: {sms} SMS"
pricedFixedText

Cost after fixing, when a price is set.

string"Fixed: {sms} SMS, saves {saving}"
recipientText

Recipient counts: `{n}` is filled in.

string"{n} recipient"
recipientsText

Recipient count label for several recipients.

string"{n} recipients"

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

How is SMS Segments accessible?

  • Visible <label>; meter and warning linked via aria-describedby
  • Parts are buttons in a labelled group, each with an aria-label to select it
  • Warning renders in a polite live region; each fix has an aria-label
  • Highlight animation skipped under reduced motion

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

What are the limitations and server boundaries?

  • Assumes standard concatenation; some carriers or national shift tables differ
  • Cost uses the price you pass; carriers may bill differently
  • Replacing characters changes the text the recipient sees

What validation rules apply to SMS Segments?

Rules last verified:

Confirmed: 160 GSM 7-bit characters in 140 octets and the default alphabet extension table. The 153/67 per-part figures come from the concatenation header in 3GPP TS 23.040, not re-checked this round. Copied components don't update themselves, so re-check after rule changes (see updating a component).

What expensive mistakes does SMS Segments stop?

One emoji doubled the SMS bill

Also known as

sms · character count · gsm-7 · ucs-2 · segments · bulk sms · otp sms · twilio

Field type

What dependencies does SMS Segments require?

SMS Segments facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameSMS Segments
Registry identifier@bollard/sms-segments
Install commandnpx shadcn@latest add @bollard/sms-segments
LicenseMIT License (free, commercial-friendly)
Price$0 (100% Free and Open Source)
Version0.1.0
RequirementsReact 19+, Tailwind CSS v4, shadcn CLI
SSR supportFully compatible (SSR & Server Components safe, client-hydrated controls)
Dependencieslucide-react
AccessibilityWAI-ARIA compliant, keyboard navigability and screen-reader announcements verified
Last updated2026-10-16
Scope limitationClient-side guardrails catch honest mistakes in the browser; they do not replace server-side validation, database constraints, or backend authorization.

Frequently asked questions about SMS Segments

How does SMS Segments validate Indian financial identifiers?

SMS Segments stops one emoji doubled the SMS bill. Complies with national standards for Characters outside GSM-7 that force UCS-2 (curly quotes, emoji, look-alikes), Extension characters (€, [, ~) that use two septets, Part count and cost per recipient count, Never splits a 2-septet character or surrogate pair across parts, One-tap replace or remove of each culprit. Limitation: verify sms-segments with issuer gateway.

How do I install sms-segments with shadcn?

Run `npx shadcn@latest add @bollard/sms-segments`. Sources added: registry/default/sms-segments/sms-segments.tsx. Package requirements: lucide-react.

What props customize SMS Segments?

SMS Segments accepts `label`, `value`, `defaultValue`, `onValueChange`, `recipients`. Configures sms, character count, gsm-7 behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of sms-segments?

Assumes standard concatenation; some carriers or national shift tables differ. Cost uses the price you pass; carriers may bill differently. Replacing characters changes the text the recipient sees Server requirement: backend verification for sms-segments.

How does SMS Segments meet accessibility guidelines?

Visible <label>; meter and warning linked via aria-describedby. Parts are buttons in a labelled group, each with an aria-label to select it. Warning renders in a polite live region; each fix has an aria-label. Highlight animation skipped under reduced motion. Minimizes errors: sms costs double, emoji makes sms ucs-2.

Which components pair with SMS Segments?