Mention input
A textarea with @people and #channel mentions that act as single tokens, with suggestions at the caret.
npx shadcn@latest add @silicon-ui/mention-inputInstallation
With the shadcn CLI
npx shadcn@latest add @silicon-ui/mention-inputManually
Install the dependencies
npm install lucide-react motionCopy these files into your project
- components/silicon-ui/mention-input/mention-input.tsx
- components/silicon-ui/mention-input/mention-input.module.css
Shared with other components. Skip any you already have.
- components/silicon-ui/lib/fluid-hover.tsx
Add the foundation, once per app, for the design and motion tokens
npx shadcn@latest add @silicon-ui/silicon-foundation
Usage
API reference
| Prop | Type | Default |
|---|---|---|
value | MentionValue | — |
defaultValue | MentionValue | — |
onChange | (value: MentionValue) => void | — |
peoplePeople offered after `@`. Leave it out to turn person mentions off. | MentionPerson[] | — |
channelsChannels offered after `#`. Leave it out to turn channel mentions off. | MentionChannel[] | — |
onMentionAddCalled when a suggestion becomes a mention. | (mention: Mention) => void | — |
onSubmitWith `submitOnEnter`, Enter submits and Shift+Enter adds a line. | (value: MentionValue) => void | — |
submitOnEnter | boolean | false |
placeholder | string | — |
minRows | number | 1 |
maxRowsThe field grows to this many rows, then scrolls. | number | 8 |
placementWhere suggestions open. `auto` flips above when there is no room below. | "auto" | "top" | "bottom" | "auto" |
maxSuggestions | number | 6 |
disabled | boolean | — |
name | string | — |
id | string | — |
aria-label | string | — |
aria-describedby | string | — |
className | string | — |
Also accepts the props of HTMLAttributes.
Dependencies
- npm
- lucide-reactmotion
- Registry
- silicon-motion-tokens