vercel / vercel/ai-elements

Allow PromptInput to contain rich text input with clickable @mentions and /slash commands

Open
#179 2 comments 35 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
TypeScript
Stars
2.4k
Forks
283
Avg merge
32m
Merged PRs (30d)
1

Description

Implement a rich text input component that allows users to insert clickable command elements using @ or / prefixes. These elements should render as styled, interactive tokens within the textarea, similar to Twitter's mention functionality.

When a user types @ or /, an autocomplete dropdown appears with suggestions. Selecting an item inserts it as a visually distinct, clickable token that can be interacted with or removed.

Example Use Cases

  • @mentions: Tag files, reference data sources, or link to context
  • /commands: Insert slash commands to trigger e.g., tools or custom prompts

References

How it works in other apps

Cursor

Image

ChatGPT

Image Image Image

Depending on how we decide to implement this, having a full blown WYSIWYM editor (even if headless) could likely increase bundle size by a bit for simple use cases that do not need such functionality, so tree shaking, dynamic imports would be good to consider. Likewise, we could create a custom, more lightweight solution similar to what e.g., react-mentions does.

Regardless of the approach, I think this will be a good feature to have not only for our <PromptInput /> component but also to potentially include the Canvas Editor that Chat SDK has into AI Elements: https://github.com/vercel/ai-chatbot/blob/main/components/text-editor.tsx#L164 (which uses prosemirror at the moment).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the PromptInput component and reviewing the referenced Canvas Editor at components/text-editor.tsx, then compare the suggested Lexical, ProseMirror, Tiptap, and react-mentions approaches. Done means @mentions and /commands show autocomplete suggestions, become styled clickable tokens that can be removed, and the approach accounts for bundle-size impact.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.