Hashtags & Mentions UI Implementation
Overview
The hashtag and mention autocomplete feature has been integrated into the social post creation form, providing real-time suggestions as users type.
Component: CaptionInputWithSuggestions
Location
/src/admin/components/social-posts/caption-input-with-suggestions.tsx
Features
-
Real-Time Detection
- Detects when user types
#for hashtags - Detects when user types
@for mentions - Shows suggestions automatically
- Detects when user types
-
Smart Suggestions
- Hashtags: Shows matching hashtags as you type, or popular hashtags when you just type
# - Mentions: Shows matching usernames and display names
- Usage Count: Displays how many times each hashtag/mention has been used
- Hashtags: Shows matching hashtags as you type, or popular hashtags when you just type
-
Keyboard-Friendly
- Click to insert suggestion
- Automatically adds space after insertion
- Maintains cursor position
-
Platform-Aware
- Filters suggestions based on selected platform
- Supports: Facebook, Instagram, Twitter, or "all"
Usage
import { CaptionInputWithSuggestions } from "./caption-input-with-suggestions"
<CaptionInputWithSuggestions
value={caption}
onChange={setCaption}
placeholder="Write your caption..."
platform="instagram"
/>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | - | Current caption text |
onChange | (value: string) => void | - | Callback when text changes |
placeholder | string | "Write your caption..." | Placeholder text |
platform | "facebook" | "instagram" | "twitter" | "all" | "all" | Platform for filtering suggestions |
disabled | boolean | false | Disable input |
Integration in Create Post Form
The component has been integrated into all caption/message fields in the create social post form:
Facebook Posts
<CaptionInputWithSuggestions
value={value || ""}
onChange={onChange}
placeholder="Say something about this post... Use # for hashtags and @ for mentions"
platform="facebook"
/>
Instagram Posts
<CaptionInputWithSuggestions
value={value || ""}
onChange={onChange}
placeholder="Write a caption... Use # for hashtags and @ for mentions"
platform="instagram"
/>