Mention Guard

Mention Guard is a copy-paste React component that stops @channel pinged 1,240 people 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/mention-guard
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

Stops@channel pinged 1,240 people

Was this component page useful?

How do I install Mention Guard?

pnpm dlx shadcn@latest add @bollard/mention-guard

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

How do I use Mention Guard in React?

mention-guard-usage.tsx
import { MentionGuard, type MentionContext, type MentionPerson } from "@/components/ui/mention-guard"

<MentionGuard
  conversation="#launch"
  label="Reply in #launch"
  context={context}
  defaultValue="@channel the launch review moved to 4 pm IST. @rahul can you bring the deck?"
  onInvite={(person) => setPeople((list) => list.map((p) => (p.handle === person.handle ? { ...p, inConversation: true } : p)))}
  onSend={(text) => new Promise<void>((resolve) => setTimeout(() => (setSent(text), resolve()), 500))}
/>

What input mistakes does Mention Guard catch?

  • Broadcast mentions over a threshold, with the count
  • Recipients in other time zones
  • Mentioned people who aren't in the conversation or can't open it
  • Double press on Send: the confirm can't be triggered by it
  • Ignores emails (a@here.com) and code spans

What props does Mention Guard accept?

MentionGuard props
PropTypeDefault
value

Controlled message text.

string—
defaultValue

Initial text when uncontrolled.

string""
onValueChange

Called with the text on every change.

(value: string) => void—
onSend* (required)

Sends the message. Return a promise to show a pending state; the text clears when it resolves.

(text: string) => void | Promise<void>—
onInvite

Invites a mentioned person into the conversation. Without it, only "Remove mention" is offered.

(person: MentionPerson) => void—
conversation* (required)

Where the message goes, e.g. "#launch".

string—
context* (required)

Who each

MentionContext—
threshold

Audiences at or above this size need a confirm before sending. Slack uses 6.

number6
softerHandle

Handle to suggest instead of a broadcast, e.g. "here" (only people online).

string"here"
sendOnEnter

Enter sends and Shift+Enter adds a line. Off: only Ctrl/⌘+Enter sends.

booleantrue
label

Visible label.

string"Message"
placeholder

Textarea placeholder.

string—
broadcastText

Templates. `{handle}`, `{count}`, `{zones}`, `{name}` and `{conversation}` are filled in.

string"@{handle} notifies {count} people"
zonesText

Template for how many are in other time zones.

string", {zones} in other time zones"
outsiderText

Shown for a mentioned person not in the conversation.

string"{name} isn't in {conversation} and won't be notified."
noAccessText

Shown when a mentioned person can't open the conversation.

string"{name} can't see {conversation}, so they won't see this."
softerLabel

Button text to swap for the softer handle.

string"Use @{handle} ({count})"
silenceLabel

Button text to mention without notifying.

string"Don't notify"
inviteLabel

Button text to invite a mentioned person.

string"Invite {name}"
removeLabel

Button text to remove a mention.

string"Remove mention"
sendLabel

Send button text.

string"Send"
confirmLabel

Confirm button template for a broadcast.

string"Notify {count} people"
confirmOutsiderLabel

Confirm button text when outsiders are mentioned.

string"Send anyway"
cancelLabel

Cancel button text while armed.

string"Edit"
sendingLabel

Button text while sending.

string"Sending…"
armedHint

Read to screen readers when Send asks for a second press.

string"Check the warnings, then press Send again. Escape to kee…

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

How is Mention Guard accessible?

  • Visible label; textarea is described by a polite notice region
  • Escape cancels the armed confirm; IME composition doesn't trigger send
  • Confirm pulse is skipped under reduced motion
  • Fixes are buttons; icons are aria-hidden

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

What are the limitations and server boundaries?

This is a UX guard rail. Enforce on the server: Rate-limit and permission-check broadcast mentions on the server.

  • Audience sizes come from your context prop
  • Doesn't stop sending through other clients or the API
  • Mentions are parsed with simple rules; custom mention syntax needs adapting

What expensive mistakes does Mention Guard stop?

@channel pinged 1,240 people

Also known as

@channel · @everyone · @here · mentions · slack · discord · notify · group mention

Field type

What dependencies does Mention Guard require?

Mention Guard facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameMention Guard
Registry identifier@bollard/mention-guard
Install commandnpx shadcn@latest add @bollard/mention-guard
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 Mention Guard

What form validation mistake does Mention Guard catch?

Mention Guard prevents @channel pinged 1,240 people. Says how many people @channel, @everyone or a group mention will notify as you type, and asks for an explicit confirm before a mass ping. Catches: Broadcast mentions over a threshold, with the count, Recipients in other time zones, Mentioned people who aren't in the conversation or can't open it, Double press on Send: the confirm can't be triggered by it, Ignores emails (a@here.com) and code spans. Limitation: validate mention-guard schemas on backend.

How do I install mention-guard with shadcn?

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

What props customize Mention Guard?

Mention Guard accepts `value`, `defaultValue`, `onValueChange`, `onSend`, `onInvite`. Configures @channel, @everyone, @here behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of mention-guard?

Audience sizes come from your context prop. Doesn't stop sending through other clients or the API. Mentions are parsed with simple rules; custom mention syntax needs adapting Server requirement: Rate-limit and permission-check broadcast mentions on the server.

How does Mention Guard meet accessibility guidelines?

Visible label; textarea is described by a polite notice region. Escape cancels the armed confirm; IME composition doesn't trigger send. Confirm pulse is skipped under reduced motion. Fixes are buttons; icons are aria-hidden. Minimizes errors: accidental @everyone, @channel at night.

Which components pair with Mention Guard?