Componentmedia0.39 KB gzipZero dependencies

Mention Highlight

Highlight @mentions and #hashtags inside running text.

Preview

Live Preview
Open ↗

Installation

Tokens guide →

Add to your project via CLI (zero dependencies, code you own):

npx bigbullui add mention-highlight

Or install the full npm package:

npm install bigbullui

Usage

tsx3 lines
import { MentionHighlight } from "@/components/ui/mention-highlight"; <MentionHighlight />

Source code

mention-highlight.tsx + 1 helper

Zero third-party dependencies (2 local files shown in tabs below).

tsxmention-highlight.tsx39 lines
"use client"; import * as React from "react";import { cn } from "./lib/utils"; export interface MentionHighlightProps extends React.HTMLAttributes<HTMLParagraphElement> {  text: string;} /** Text highlighter for @mentions and #tags. */export function MentionHighlight({ text = "", className, ...props }: MentionHighlightProps) {  const parts = React.useMemo(    () => text.split(/(@[A-Za-z0-9_]+|#[A-Za-z0-9_]+)/g),    [text]  );   return (    <p className={cn("text-sm leading-relaxed", className)} {...props}>

Props

Interactive Prop Playground

Tweak parsed AST props below to generate ready-to-paste JSX.

tsx3 lines
import { MentionHighlight } from "@/components/ui/mention-highlight"; <MentionHighlight />
PropTypeDescription
textstringConfigures text. (Default: "")