Character Budget

Character Budget is a copy-paste React component that stops post cut off or sms costs double 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/char-budget
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

StopsPost cut off or SMS costs double

Was this component page useful?

How do I install Character Budget?

pnpm dlx shadcn@latest add @bollard/char-budget

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

How do I use Character Budget in React?

char-budget-usage.tsx
import { CHAR_TARGETS, CharBudget } from "@/components/ui/char-budget"

<CharBudget
  label="Launch announcement"
  defaultValue={"Bollard UI is live! Components that stop users from making mistakes — undo toasts, hold-to-confirm, and more. It’s free & open source… try it today 🚀 https://bollard-ui.dev"}
  targets={[
    CHAR_TARGETS.x,
    CHAR_TARGETS.sms,
    CHAR_TARGETS.meta,
    { kind: "graphemes", label: "Push notification", limit: 110 },
  ]}
/>

What input mistakes does Character Budget catch?

  • Text over each platform's limit, counted as people see characters (emoji and flags count once)
  • X's weighting (URLs as 23, emoji and CJK as 2)
  • Characters that force UCS-2 and shrink an SMS segment from 160 to 70
  • Extra SMS segments

What props does Character Budget accept?

CharBudget 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—
targets

Limits to check at once; defaults to X, SMS, LinkedIn and a meta description.

CharTarget[]Object.values(CHAR_TARGETS)
ucs2Message

Text of the warning shown when a character forces the SMS into UCS-2.

string"These switch the SMS to UCS-2, 70 characters per part in…
plainLabel

Label of the fix that swaps curly quotes, dashes and ellipses for plain ones.

string"Use plain characters"
messages

Reword or translate the counter's labels and announcements.

Partial<typeof CHAR_BUDGET_MESSAGES>—

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

How is Character Budget accessible?

  • Visible <label>; the field is described by an aria-live="polite" summary
  • Buttons that find a problem character have aria-labels naming it
  • Finding a character moves focus to it in the field

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

What are the limitations and server boundaries?

  • Platform limits are built in and can change; pass your own targets to override
  • Falls back to code points where Intl.Segmenter is unavailable
  • Real SMS cost also depends on the carrier and gateway

What expensive mistakes does Character Budget stop?

Post cut off or SMS costs double

Also known as

character count · char limit · tweet · x post · sms · linkedin · meta description · textarea

Field type

What dependencies does Character Budget require?

Character Budget facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameCharacter Budget
Registry identifier@bollard/char-budget
Install commandnpx shadcn@latest add @bollard/char-budget
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 Character Budget

What form validation mistake does Character Budget catch?

Character Budget prevents post cut off or SMS costs double. Counts text against X, SMS, LinkedIn and meta-description limits at once, so posts aren't cut off and SMS don't silently cost double. Catches: Text over each platform's limit, counted as people see characters (emoji and flags count once), X's weighting (URLs as 23, emoji and CJK as 2), Characters that force UCS-2 and shrink an SMS segment from 160 to 70, Extra SMS segments. Limitation: validate char-budget schemas on backend.

How do I install char-budget with shadcn?

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

What props customize Character Budget?

Character Budget accepts `label`, `value`, `defaultValue`, `onValueChange`, `targets`. Configures character count, char limit, tweet behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of char-budget?

Platform limits are built in and can change; pass your own targets to override. Falls back to code points where Intl.Segmenter is unavailable. Real SMS cost also depends on the carrier and gateway Server requirement: backend verification for char-budget.

How does Character Budget meet accessibility guidelines?

Visible <label>; the field is described by an aria-live="polite" summary. Buttons that find a problem character have aria-labels naming it. Finding a character moves focus to it in the field. Minimizes errors: character limit tweet, sms emoji costs double.

Which components pair with Character Budget?